1

我有一个应用程序,里面有两个栏。其中一个选项卡 .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]]; 
}

什么也没发生,控制台根本没有显示任何错误。

似乎是什么问题?

谢谢!

4

1 回答 1

1

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

于 2012-02-06T12:03:16.963 回答