0

I am new in using Three20, when i use navigator, the xcode always report error:Application windows are expected to have a root view controller at the end of application launch

here is my code:

TTNavigator *navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeAll;
navigator.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

TTURLMap *map = navigator.URLMap;
[map from:@"tt//view" toViewController:[ViewController class]];
[map from:@"tt//test" toSharedViewController:[TestViewController  class]];
if (![navigator restoreViewControllers]) {
    [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://view"] ];
}

return YES;

I don't why this happened? Can anyone help me out?

zachjs
  • 1,738
  • 1
  • 11
  • 22
leoyfm
  • 241
  • 4
  • 16

1 Answers1

0

I've run into similar problems before because the view controller hierarchy isn't being created by a nib file.

The solution is to manually set the root view controller after your call to restoreViewControllers:

TTNavigator *navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeAll;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
navigator.window = self.window;

TTURLMap *map = navigator.URLMap;
[map from:@"tt//view" toViewController:[ViewController class]];
[map from:@"tt//test" toSharedViewController:[TestViewController  class]];
if (![navigator restoreViewControllers]) {
    [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://view"] ];
}

// Set the root view controller
[self.window setRootViewController:navigator.rootViewController];

return YES;
Funktional
  • 4,083
  • 1
  • 30
  • 27