问题
[sorry for my weak english]
I have some method to create and show some new view controler (on top of my current view controler level)
- (void) switchToDifficultyMenu
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DifficultyMenuController *difficultyMenuController = [[DifficultyMenuController alloc] init];
NSLog(@"navigation controller %@" , self.navigationController); //navContr is nil
[self.navigationController pushViewController: difficultyMenuController animated: NO];
[difficultyMenuController release];
[pool release];
}
it works when i fire it for example from under tap events on my current view controller, but when i try to call it immediately when my current view controler loads (it is some need for that) id est in its -viewdidLoad the navigationController is nil
how can i make it work, much tnx
回答1:
Until you don't push your UIViewController into an UINavigationController, the navigationController property will be null. The viewDidLoad method is always called before the push. So in the viewDidLoad, there is no way to access this property.
来源:https://stackoverflow.com/questions/7497183/problem-with-navigationcontroller