通过通过url routing解决UIViewController跳转依赖
XYRouter
https://github.com/uxyheaven/XYRouter
XYRouter是一个通过url routing来解决UIViewController跳转依赖的类.
* 本类採用ARC
Installation
- 本库基于ARC
- 拷贝XYQuick到项目里
- 在须要用的文件或者pch里
#import "XYRouter.h"
Podfile
pod 'XYRouter'
#import "XYRouter.h"
Usage
Creating viewController map
能够通过key和NSString来映射一个UIViewController
[[XYRouter sharedInstance] mapKey:@"aaa" toControllerClassName:@"UIViewController"];
Getting viewController for key
当取出ViewController的时候, 假设有单例[ViewController sharedInstance], 默认返回单例, 假设没有, 返回[[ViewController alloc] init].
UIViewController *vc = [[XYRouter sharedInstance] viewControllerForKey:@"aaa"];
Maping a viewController instance
假设不想每次都创建对象, 也能够直接映射一个实例
[[XYRouter sharedInstance] mapKey:@"bbb" toControllerInstance:[[UIViewController alloc] init]];
Maping a viewController instance with a block
假设想更好的定制对象, 能够用block
[[XYRouter sharedInstance] mapKey:@"nvc_TableVC" toBlock:^UIViewController *{
TableViewController *vc = [[TableViewController alloc] init];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
return nvc;
}];
Opening path
你能够使用key去push出一个viewController
[[XYRouter sharedInstance] openUrlString:@"aaa"];
path还支持相对路径, 如以下的代码能够在当前文件夹下push出一个TableVC后, 再push出TestVC1.
[[XYRouter sharedInstance] openUrlString:@"./TableVC/TestVC1"];
眼下支持这些描写叙述:
- 在当前文件夹push
./ - 在上一个文件夹push
../ - 在根文件夹根push
/
Assigning parameters
在跳转的时候还能够传递參数
@interface TestVC1 : UIViewController
@property (nonatomic, assign) NSInteger i;
@property (nonatomic, copy) NSString *str1;
@property (nonatomic, copy) NSString *str2;
@end
[[XYRouter sharedInstance] openUrlString:@"TestVC1?str1=a&str2=2&i=1"];
Changing rootViewController
能够用scheme:window替换windows.rootViewController
// rootViewController : nvc_TableVC
[[XYRouter sharedInstance] openUrlString:@"window://nvc_TableVC/TestVC1"];
Presenting rootViewController
能够用scheme:modal来呈现一个模态视图
// rootViewController : nvc_TableVC
[[XYRouter sharedInstance] openUrlString:@"modal://nvc_TableVC/TestModalVC/"];
// rootViewController : TestModalVC
[[XYRouter sharedInstance] openUrlString:@"modal://TestModalVC/?str1=a&str2=2&i=1"];
Dismissing rootViewController
关闭这个模态视图直接用dismiss
[[XYRouter sharedInstance] openUrlString:@"dismiss"];通过通过url routing解决UIViewController跳转依赖的更多相关文章
- 转:【WebDriver】封装GET方法来解决页面跳转不稳定的问题
在大多数测试环境中,网络或者测试服务器主机之间并不是永远不出问题的,很多时候一个客户端的一个跳转的请求会因为不稳定的网络或者偶发的其它异常hang死在那里半天不动,直到人工干预动作的出现. ...
- [ASP.NET MVC 小牛之路]07 - URL Routing
我们知道在ASP.NET Web Forms中,一个URL请求往往对应一个aspx页面,一个aspx页面就是一个物理文件,它包含对请求的处理. 而在ASP.NET MVC中,一个URL请求是由对应的一 ...
- ASP.NET MVC 学习之路由(URL Routing)
在ASP.NET MVC中,一个URL请求是由对应的一个Controller中的Action来处理的,由URL Routing来告诉MVC如何定位到正确的Controller和Action. 默认路由 ...
- URL Routing
们知道在ASP.NET Web Forms中,一个URL请求往往对应一个aspx页面,一个aspx页面就是一个物理文件,它包含对请求的处理. 而在ASP.NET MVC中,一个URL请求是由对应的一个 ...
- 控制器 - URL routing HTTP module(一)
URL routing HTTP module 负责处理检查入站请求的 URL,并将它们分派到最合理的处理器上.URL routing HTTP module 也替代了旧版本的 ASP.NET URL ...
- 【ASP.NET MVC 学习笔记】- 08 URL Routing
本文参考:http://www.cnblogs.com/willick/p/3343105.html 1.URL Routing告诉MVC如何正确的定位Controller和Action. 2.URL ...
- ios访问web页面<div>点击事件不起效果,以及alert()显示url的解决办法
ios访问web页面<div>点击不起效果,在其div上添加style=”cursor:pointer:“ jquery web页面动态append()事件调用方法:$(document) ...
- [译]Angular-ui 之 Url Routing
◄ 前一篇 (Multiple Named Views) 下一篇 (The Components) ► 在你的应用中多数的状态都是基于特定的url地址的.Url Routing机制绝不是在状态 ...
- spring如何解决单例循环依赖问题?
更多文章点击--spring源码分析系列 1.spring循环依赖场景2.循环依赖解决方式: 三级缓存 1.spring循环引用场景 循环依赖的产生可能有很多种情况,例如: A的构造方法中依赖了B的实 ...
随机推荐
- Visual Studio 安装VS10x CodeMAP
最近出差,用的是公司电脑,电脑安装的是Visual Studio 2017 VS10x CodeMap 支持Visual Studio 2010, 2012, 2013, 2015,不支持Visual ...
- 在已有的mysql表中添加自增字段
现有数据表xiami,建表的时候忘记添加自增字段,现需要添加自增字段 第一步:添加字段 alter table xiami add id int; 第二步:修改字段 alter tabel xiami ...
- scanf_s读取键盘输入字符串失败
#include<stdio.h> int main() { ]; ]; printf("Input string:\n"); scanf_s("%s&quo ...
- 枚举(enum)的使用
在开发中我们经常会遇到一些特殊的字段,比如订单状态.支付状态.类型等,这些特殊字段在编码开发的时候,可以写成枚举类型.接下来还是看Demo吧! public enum AuditState { Wai ...
- CSS3---关于文本
1.text-overflow用来设置是否使用一个省略标记(...)标示对象内文本的溢出. 2.但是text-overflow只是用来说明文字溢出时用什么方式显示,要实现溢出时产生省略号的效果,还须定 ...
- Couchbase IV(管理与维护)
Couchbase IV(管理与维护) 管理 常用命令 Command Description server-list List all servers in a cluster server-inf ...
- 大数据学习——linux常用命令(二)
二.目录操作 1 查看目录信息 ls / 查看根目录下的文件信息 ls . 或者 ls ./查看当前目录下的文件信息 ls ../查看根目录下 ls /home/hadoop ls -l . 查看当前 ...
- HDU 5076 Memory
Memory Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 50 ...
- Robberies(01背包)
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually g ...
- private、protected和public的区别
private 是完全私有的,只有当前类中的成员能访问到. protected 是受保护的,只有当前类的成员与继承该类的类才能访问. 这两个是访问类中成员权限的限制符.在类外如果想使用类中的成员,只能 ...