toViewController、toSharedViewController 和 toModalViewController 之间的区别
与 TTURLMap
一起使用时,toViewController
、toSharedViewController
和 toModalViewController
之间有什么区别?
TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://tabBar" toSharedViewController:[TabBarController class]];
[map from:@"tt://order?waitress=(initWithWaitress:)"
toModalViewController:[ContentController class]];
What are the differences between toViewController
, toSharedViewController
and toModalViewController
when used with TTURLMap
?
TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://tabBar" toSharedViewController:[TabBarController class]];
[map from:@"tt://order?waitress=(initWithWaitress:)"
toModalViewController:[ContentController class]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
(void)from:(NSString*)URL toViewController:(id)target
将始终从头开始重新创建 UIViewController,并且不会尝试重用现有的视图控制器。例如,如果您调用
TTOpenURL(@"tt://details/view/1)
两次,它将创建视图控制器两次。另一方面,如果您使用
( void)from:(NSString*)URL toSharedViewController:(id)target
,TTNaviagtor
将以共享模式创建控制器并重用它们,这对于选项卡栏视图中的菜单很有用。如果你打电话
TTOpenURL(@"tt://menu/1)
对于使用 toSharedViewController 创建的 url 两次,它将重用现有的视图控制器(如果控制器位于 TTNavigator 堆栈中并且未发布)通过内存警告)最后一个选项
(void)from:(NSString*)URL toModalViewController:(id)target
将通过推送视图控制器来显示视图控制器,而不使用现有的UINavigationBar
。如果您需要呈现“发送电子邮件”视图或已有 UINavigationBar 的视图,这会很有帮助。Using
(void)from:(NSString*)URL toViewController:(id)target
will always recreate the UIViewController from scratch and won't try to reuse an existing view controller.So for example, if you call
TTOpenURL(@"tt://details/view/1)
twice, it will create the view controller twice.On the other hand, if you use
(void)from:(NSString*)URL toSharedViewController:(id)target
, theTTNaviagtor
will create the controllers in shared mode and reuse them. It's good for menus in tab bar views.so if you call
TTOpenURL(@"tt://menu/1)
twice for a url that was created with toSharedViewController, it will reuse an existing view controller (if the controller is in the TTNavigator stack and wasn't released by a memory warning)the last option,
(void)from:(NSString*)URL toModalViewController:(id)target
will display the view controller by pushing it without using the existingUINavigationBar
. It's helpful if you need to present a "send email" view, or something that already has a UINavigationBar.