通过通过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的实 ...
随机推荐
- Navicat Premium 12试用期的破解方法
参考:https://blog.csdn.net/Jason_Julie/article/details/82864187 已测可用
- react-native 在新版Xcode(10+)中运行出现的问题: node_modules/react-native/third-party/glog-0.3.4 , C compiler cannot create executables
报错发生在 react-native : 0.55.4 (或存在于更低的版本) 报错: ----/node_modules/react-native/third-party/glog-0.3.4': ...
- bzoj2588 counting on a tree
题目不难,树上可持久化数据结构. 帖代码: #include<cstdio> #include<algorithm> using namespace std; #define ...
- go语言碎片整理之标准库log
log Go语言内置的log包实现了简单的日志服务.本文介绍了标准库log的基本使用. 使用Logger log包定义了Logger类型,该类型提供了一些格式化输出的方法.本包也提供了一个预定义的“标 ...
- 【01】魔芋使用MDN的一点点经验
[01]魔芋使用MDN的一点点经验 1,MDN地址: https://developer.mozilla.org/en-US/(下图) 2,建议看英文原文.因为中文翻译落后,并且有些翻译并 ...
- [Go]字典(map)的操作和约束
字典(map)存储的是键值对(key-value pair,一个键值对代表了一对键和值.一个键和一个值分别代表了一个从属于某一类型的独立值,把它们两个捆绑在一起就是键值对,也称“键-元素对”)的集合 ...
- oracle如何向空表中添加一个类型为clob的非空列
一般的添加非空列的步骤是:先add可以为空的列,然后update该列为一个值(比如0),最后modify该列的类型 但是遇到类型为clob的就不行了.在modify这步时报错:ORA-22296:in ...
- @Temporal()注解的使用
数据库的字段类型有date.time.datetime而Temporal注解的作用就是帮Java的Date类型进行格式化,一共有三种注解值: 第一种:@Temporal(TemporalType.DA ...
- django学习之- Ajax
提示:jquery要使用1版本,因为高版本已不兼容低版本的游览器.参考url:http://www.cnblogs.com/wupeiqi/articles/5703697.html原生ajax:Aj ...
- poj -1185 炮兵阵地 (经典状压dp)
http://poj.org/problem?id=1185 参考博客:http://poj.org/problem?id=1185 大神博客已经讲的很清楚了,注意存状态的时候是从1开始的,所以初始化 ...