简体   繁体   English

Three20:通过TTNavigator恢复时没有调用loadView和viewDidLoad

[英]Three20: loadView and viewDidLoad not called when restoring through TTNavigator

When using the the Three20 framework I have a problem with the way how TTNavigator seems to work.使用 Three20 框架时,我对 TTNavigator 的工作方式有疑问。 If in applicationDidFinishLaunching I restore the previous state of the app with:如果在 applicationDidFinishLaunching 中,我使用以下命令恢复应用程序以前的 state:

TTNavigator* navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeAll;
navigator.window = self.window;
[navigator restoreViewControllers];

The methods loadView and viewDidLoad of the ViewController that was just restored never get called.刚刚恢复的 ViewController 的 loadView 和 viewDidLoad 方法永远不会被调用。 How can that be so?怎么会这样?

Is that a bug or by design?这是一个错误还是设计使然?

If it's by design, what would be a good fix.如果它是设计使然,那将是一个很好的解决方案。 My problem is that I want the ViewController to load its nib.我的问题是我希望 ViewController 加载它的笔尖。 I've seen other workarounds, but they are ugly and have outside component (like the app delegate instead of the view controller itself) load the nib, which I would like to avoid.我见过其他解决方法,但它们很丑陋并且有外部组件(比如应用程序委托而不是视图 controller 本身)加载笔尖,我想避免这种情况。 An example of those ugly workarounds is given in the TTNibDemo example that ships with the Three20 source code. Three20 源代码附带的 TTNibDemo 示例中给出了这些丑陋解决方法的示例。

It depends in what way you are calling viewController, try in viewWillAppear, should work.这取决于您调用 viewController 的方式,在 viewWillAppear 中尝试应该可以工作。

Are you testing on device?你在设备上测试吗?

navigator.window = self.window;导航器.window = self.window; _ [navigator restoreViewControllers]; _ [导航器恢复视图控制器];

On the device the first screen is always the first screen, whereas on the simulator that is not the case, and you should always check before with the condition在设备上,第一个屏幕始终是第一个屏幕,而在模拟器上并非如此,您应该始终检查之前的条件

if(![navigator restoreViewControllers])
  // do this
else 
  TTNavigationController* navi = [[((MyViewController1*)[navigator topViewController]) viewControllers] objectAtIndex:0];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM