problem with navigationController

元气小坏坏 提交于 2019-12-13 04:24:25

问题


[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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!