PushViewController 不工作,因为 self.navigationController 为 null
我有一个大问题:在方法 didSelectRowAtIndexPath
上,我总是为 self.navigationController 获取 null 。我有一个 UIViewController,其中包含一个 UIsegmentedControl 和一个子视图。在此子视图上,我为所选的每个段添加控制器。对于每个段都有一个表视图。问题是:当我从此表视图中选择一行时,我无法推送下一个控制器,因为 self.navigationController 为空。
请帮助我..这是我的代码: http://pastebin.com/qq0vf7mq
没有代码:
navigationTelephone=[[UINavigationController alloc] init];
[self.view addSubview:self.navigationTelephone.view];
[self.navigationTelephone setNavigationBarHidden:YES];
[self.view addSubview:tableViewTelephone];
I have a big problem: on method didSelectRowAtIndexPath
I always get null to self.navigationController. I have a UIViewController that contains a UIsegmentedControl and a subView. On this subView I add the controllers for each segment selected. For each segment a have a tableview. Here is the problem: when I select a row from this tableview I can't do push for next controller because self.navigationController is null.
Please help me..Here is my code : http://pastebin.com/qq0vf7mq
without the code :
navigationTelephone=[[UINavigationController alloc] init];
[self.view addSubview:self.navigationTelephone.view];
[self.navigationTelephone setNavigationBarHidden:YES];
[self.view addSubview:tableViewTelephone];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为您已经初始化了 UINavigationController,如下所示
I think You have initialize the UINavigationController like below
更新:
您初始化一个实例变量
navigationTelephone
并显示它,但您使用self.navigationController
来推送!使用
[navigationTelephone Push...]
代替Updated:
You initialize an instance variable
navigationTelephone
and display it, but you useself.navigationController
to push!Use
[navigationTelephone push...]
instead试试这个:
您还没有实例化 myaudiPhoneViewController,这就是它不推送视图的原因。
Try this one:
You haven't instantiate your myaudiPhoneViewController that is why it's not pushing the view.
只需更改一下即可检查,
Naveen Shan
Just check by changing,
Naveen Shan