2011-10-03 405 views
1

我有一个很大的问题:方法didSelectRowAtIndexPath我总是得到null self.navigationController。我有一个UIViewController,它包含一个UIsegmentedControl和一个子视图。在这个子视图中,我为每个选定的段添加控制器。对于每个段有一个tableview。这里是问题:当我从这个tableview中选择一行时,我无法推送下一个控制器,因为self.navigationController为空。pushviewcontroller不工作,因为self.navigationController为空

请帮me..Here是我的代码:http://pastebin.com/qq0vf7mq

无代码:

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

你的应用程序是基于导航或任何其他基于应用 – Narayana

+0

是基于引导 – Gabrielle

回答

0

我认为你必须初始化的UINavigationController像下面

[[UINavigationController alloc] initWithRootViewController:ViewControllerOBj] 
+0

我写navigationTelephone = [[UINavigationController的页头] initWithRootViewController:self.myAudiCoordonneesViewController ]。但我得到应用程序试图推动一个无视图控制器的目标 Gabrielle

0

更新时间:

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

+0

我有它,但它不工作...不推动下一个viewcontroller – Gabrielle

0

试试这个:

- (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这就是为什么它不是推的观点。

0

通过改变只要检查,

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

纳文珊