导航控制器的问题 [英] problem with navigationController

查看:32
本文介绍了导航控制器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[抱歉我的英语不好]

我有一些方法来创建和显示一些新的视图控制器(在我的当前视图控制器级别)

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];  


}

当我从当前的点击事件中触发它时它会起作用视图控制器,但是当我尝试在当前视图控制器时立即调用它时在它的 -viewdidLoad 中加载(这是一些需要)id est,navigationController 是无

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

我怎样才能让它工作,很多 tnx

how can i make it work, much tnx

推荐答案

除非你不将 UIViewController 推送到 UINavigationControllernavigationController 属性将为空.viewDidLoad 方法总是在推送之前调用.所以在viewDidLoad中,没有办法访问这个属性.

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.

这篇关于导航控制器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆