【问题标题】:pushviewcontroller not working because self.navigationController is nullpushviewcontroller 不工作,因为 self.navigationController 为空
【发布时间】:2011-10-03 08:00:12
【问题描述】:

我有一个大问题:在方法didSelectRowAtIndexPath 上,self.navigationController 总是为空。我有一个 UIViewController,它包含一个 UIsegmentedControl 和一个 subView。在这个 subView 上,我为每个选定的段添加控制器。对于每个段都有一个表格视图。这是问题所在:当我从该表视图中选择一行时,我无法推送下一个控制器,因为 self.navigationController 为空。

请帮助我..这是我的代码:http://pastebin.com/qq0vf7mq

没有代码:

navigationTelephone=[[UINavigationController alloc] init];
    [self.view addSubview:self.navigationTelephone.view];
    [self.navigationTelephone setNavigationBarHidden:YES];
    [self.view addSubview:tableViewTelephone];

【问题讨论】:

  • 您的应用是基于导航或任何其他基于应用的应用

标签: iphone uitableview uinavigationcontroller


【解决方案1】:

我认为您已经像下面那样初始化 UINavigationController

[[UINavigationController alloc] initWithRootViewController:ViewControllerOBj]

【讨论】:

  • 我写了 navigationTelephone=[[UINavigationController alloc] initWithRootViewController:self.myAudiCoordonneesViewController];但我得到应用程序试图在目标 上推送一个 nil 视图控制器
【解决方案2】:

更新:

你初始化一个实例变量navigationTelephone并显示它,但是你使用self.navigationController来推送! 请改用[navigationTelephone push...]

【讨论】:

  • 我有它,但它不起作用...没有推送到下一个视图控制器
【解决方案3】:

试试这个:

 - (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,这就是它不推送视图的原因。

【讨论】:

    【解决方案4】:

    通过更改来检查,

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

    纳文山

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-02
      • 2011-09-29
      相关资源
      最近更新 更多