开发者

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. If in applicationDidFinishLaunching I restore the previous state of the app with:

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. 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. I've seen other workarounds, but they are ugly and have outside component 开发者_StackOverflow社区(like the app delegate instead of the view controller itself) load the nib, which I would like to avoid. An example of those ugly workarounds is given in the TTNibDemo example that ships with the Three20 source code.


It depends in what way you are calling viewController, try in viewWillAppear, should work.


Are you testing on device?

navigator.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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜