对不起,我的英语不好
我有一些方法来创建和显示一些新的视图控件(在我当前的视图控件级别之上)
- (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];
}例如,当我从当前视图控制器上的under tap事件启动它时,它可以工作,但是当我试图在当前视图控制器加载(这是需要的)其-viewdidLoad中的id est时立即调用它时,navigationController为空
我怎么才能让它工作,多tnx?
发布于 2011-09-21 18:02:41
除非您不将UIViewController推送到UINavigationController中,否则navigationController属性将为空。viewDidLoad方法总是在推送之前调用。因此,在viewDidLoad中,无法访问此属性。
https://stackoverflow.com/questions/7497183
复制相似问题