darielchen / dcurlrouter Goto Github PK
View Code? Open in Web Editor NEW通过自定义URL实现控制器之间的跳转
Home Page: http://www.jianshu.com/p/36a43202b0cd
License: MIT License
通过自定义URL实现控制器之间的跳转
Home Page: http://www.jianshu.com/p/36a43202b0cd
License: MIT License
建议添加一个控制器protocol,用于给使用者自定义控制器的初始化。
因为有的控制器可能是从 xib初始化
或者是 storyboard初始化
,而不是单单纯代码。
而目前作者的代码是简单直接的 alloc, init;
在分类UIViewController (DCURLRouter)
第 89~94
行。
if(class !=nil){
VC = [[class alloc]init];
if([VC respondsToSelector:@selector(open:withQuery:)]){
[VC open:url withQuery:query];
}
}
作者你好:
最近项目中用到你的框架,目前发现有两个问题:
建议去掉plist, 这样会让服务端控制更灵活.比如想要在线上跳转一个没有声明在plist里的的控制器 就尴尬了;
这个项目是不是只适用于单导航项目?如 tabbarcontroller 每个自控制器自带导航,或者 present 带有导航的 viewcontroller 都不行?
demo 里2presen3的时候你直接吧3设置为更控制器不好吧。。这样前两两个控制器被你注销了。
老铁 支持StoryBoard吗?
当我的工程的 根控制器 不是NavigationController 而是采用抽屉架构,导航栏只是作为抽屉的CenterVC 此时获取NavigationController为nil 返回的currentNavigationViewController是新创建UINavigationController 。这里算有个小bug吧,其实我是有导航的由于采用了抽屉架构,你没找到我的导航又新建了个导航。个人理解,如有差错,见谅。
如A->B,B pop后,需要将数据回传给A。
用微信来举例
聊天界面在 微信
Tab, 通讯录在 通讯录
Tab,从通讯录中选择一个好友 -> 点击发消息 -> 跳转到 微信
Tab 并 push 到聊天界面。
像这样的需求,DCURLRouter 能否实现?
(UIViewController *)initFromString:(NSString *)urlString fromConfig:(NSDictionary *)configDict{
// 支持对中文字符的编码
NSString *encodeStr = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
return [UIViewController initFromURL:[NSURL URLWithString:encodeStr] withQuery:nil fromConfig:configDict];
}
导致html中打不开对应的fagment
链接示例:http://some-site.com:999/dir1/dir2;param?field-1=value-1&field-2=value-2#anchor1
我们的应用做跳转思路上基本和你们的一致。
有个细节是我们所有 modal出的 都是 navigationController 然后实际的 VC 是该 nav 的 rootVC,
以此,在寻找 current VC的时候,从 appdelegate window的 rootViewController进行判断,是否为 tabbar 或者 nav , 然后对比 tabbar.selectedViewController(我们应用里面也是一个 nav) / nav 的 nav.visibleViewController != nav.topViewController 就能判断该 nav 有没有 modal 出新的页面, 如果有新的页面 则继续递归出 更上层的 nav.
可能这个方法只限规定好modal 只能 modal 出 nav 的情况. 说的不对请指正:)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.