objective-c - Three20 - 共享 View Controller 的打开 url

标签 objective-c ios three20

我知道如果使用 from:toViewController: 映射 url,然后打开该 url 将创建一个新的 View Controller ,如果使用 from:toSharedViewController 则共享将使用实例。

但是举个例子

 [map from:@"tt://tabbar/(initWithString:)" toSharedViewController:[MyTabbarController class]];
 TTOpenURL(@"tt://tabbar/string");

这将调用类似于

 [[MyTabbarController alloc] initWithString:@"string"]

但是如果稍后调用 TTOpenURL(@"tt://tabbar/somethingelse") 会发生什么? 由于使用了共享对象,因此 initWithString: 是否会在同一个实例上被调用两次?

最佳答案

答案是:没有。即,不会在已经初始化的实例上调用 init,而是分配并初始化一个新实例。

这是由于 Three20 将对象与其完整 URL 相关联,在您的情况下是“tt://tabbar/string”或“tt://tabbar/somethingelse”,因此在查询 时TTURLMap,将找不到已存在的对象并实例化一个新对象。至少,Three20 1.0.3 是这样。但我猜他们并没有改变这一点。

在我看来,共享 Controller 机制将在非常特殊的情况下使用,例如设置 View ,不应将其视为一种 Three20 实现的单例。每次我试图依靠它来更“巧妙地”使用 TTURLMap 时,我发现自己又回到了非共享 Controller 。

关于objective-c - Three20 - 共享 View Controller 的打开 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6250470/

相关文章:

iphone - 如何将 NSObject 显示为 UIView?

iphone - 在全图显示时将 UILabel 添加到 Three20 API

objective-c - UIView 模态弹出窗口带有嵌入式 UITableView 和 UIToolbar,工具栏随表格移动

ios - 当我们有 UICollectionView 时,我们应该使用 UITableView 吗?

iphone - Objective C 中嵌套引用的使用

ios如何获取应用程序启动时间?

ios - 在框架中使用 Swift 中的 ObjectiveC,无需公开 ObjC 代码

iphone - 将 TTLauncherView 从 sdk3.x 移动到 sdk4.0 为 TTLauncherItem 的徽章添加了丑陋的阴影

ios - 当应用程序在收到推送通知后变为事件状态时,在主 ViewController 上触发事件

iphone - 如何在 UIView 中使用 Facebook SLComposeViewController 而不是 UIViewController