我的项目中有一个标签栏,每个标签栏都有一个表格 View 。 单击表格 View 中的一行时,我想打开一个详细信息屏幕,如下所示。但是没有任何反应。 我做的错误在哪里。我应该如何建立逻辑。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailScreen *detail = [[DetailScreen alloc] initWithNibName:@"DetailScreen" bundle:nil];
[self.navigationController pushViewController:detail animated:YES];
[detail release];
最佳答案
点击单元格时没有任何反应的可能原因有很多。
- 在此方法中设置一个断点。它甚至被调用了吗?
- 应用程序在断点处停止后,实例初始化后转到控制台类型
po detail
。确保它不是 (null) - 同时尝试输入
po [self navigationController]
来检查导航 Controller 是否存在。
您可能没有导航 Controller 。你是如何创建 tabbarcontroller 的?在界面生成器中或通过 AppDelegate 的 didFinishLaunchingWithOptions:
方法中的代码?
你做过吗?
YourViewController *yourVC = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:yourVC];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController, nil];
关于objective-c - 无法在 TableView 中使用 pushViewController 打开详细 View 屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12296033/