PushViewController 不工作,因为 self.navigationController 为 null

发布于 2024-12-08 01:49:45 字数 621 浏览 0 评论 0原文

我有一个大问题:在方法 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

淡笑忘祈一世凡恋 2024-12-15 01:49:46

我认为您已经初始化了 UINavigationController,如下所示

[[UINavigationController alloc] initWithRootViewController:ViewControllerOBj]

I think You have initialize the UINavigationController like below

[[UINavigationController alloc] initWithRootViewController:ViewControllerOBj]
メ斷腸人バ 2024-12-15 01:49:46

更新:

您初始化一个实例变量 navigationTelephone 并显示它,但您使用 self.navigationController 来推送!
使用 [navigationTelephone Push...] 代替

Updated:

You initialize an instance variable navigationTelephone and display it, but you use self.navigationController to push!
Use [navigationTelephone push...] instead

假情假意假温柔 2024-12-15 01:49:46

试试这个:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    myAudiPhoneInputViewController *myViewController = [[myAudiPhoneViewController alloc] initWithNibName:@"NIB NAME HERE" bundile:nil];
    self.myaudiPhoneInputViewController = myViewController;
    [myViewController release];

    [tableViewTelephone deselectRowAtIndexPath:indexPath animated:NO];

    if(indexPath.row==0){

        NSLog(@"Tel.personnel... %@",self.navigationTelephone);


        [self.navigationController pushViewController:self.myaudiPhoneInputViewController animated:YES];

    }
}

您还没有实例化 myaudiPhoneViewController,这就是它不推送视图的原因。

Try this one:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    myAudiPhoneInputViewController *myViewController = [[myAudiPhoneViewController alloc] initWithNibName:@"NIB NAME HERE" bundile:nil];
    self.myaudiPhoneInputViewController = myViewController;
    [myViewController release];

    [tableViewTelephone deselectRowAtIndexPath:indexPath animated:NO];

    if(indexPath.row==0){

        NSLog(@"Tel.personnel... %@",self.navigationTelephone);


        [self.navigationController pushViewController:self.myaudiPhoneInputViewController animated:YES];

    }
}

You haven't instantiate your myaudiPhoneViewController that is why it's not pushing the view.

橘寄 2024-12-15 01:49:46

只需更改一下即可检查,

self.navigationTelephone=[[UINavigationController alloc] init];

Naveen Shan

Just check by changing,

self.navigationTelephone=[[UINavigationController alloc] init];

Naveen Shan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文