从Tab Bar应用程序上的UITableView推送新的视图控制器

时间:2011-06-16 10:17:03

标签: ios uitableview uitabbarcontroller pushviewcontroller

我有一个带有两个小节的应用程序。 其中一个选项卡.xib包含UITableView,当用户选择其中一个单元格时,我想显示另一个UIViewcontroller(。xib文件),其中包含有关其选择的信息。

现在,我试过这个

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
*)indexPath { 
NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextView" bundle:nil];   
[self.navigationController pushViewController:nextController animated:YES];     [nextController changeProductText:[arryData objectAtIndex:indexPath.row]]; 
}

没有任何反应,控制台根本没有显示任何错误。

似乎是什么问题?

谢谢!

1 个答案:

答案 0 :(得分:1)

什么都没发生,因为你的self.navigationController返回nil。 要正确使用导航控制器,您必须至少有一个。对于TabBar应用程序的情况,对于每个选项卡,您必须不关联UIViewController子类,而是关联嵌套在UINavigationController中的UIViewController子类。这在.xib或代码中都很容易完成。只需谷歌一些教程。