【发布时间】:2012-07-31 16:23:29
【问题描述】:
我在商店中有一个应用程序,它使用链接到 UIViewController (DetailController) 的 RootViewController,我正在开发一个基本上需要相同功能的新应用程序。但相反,我的新应用在 UIViewController 内有一个 UITableView,该 UIViewController 链接到 UIViewController。所以我想,我会将我的 RootViewController 代码复制并粘贴到这个新的 UIViewController 中。所以我已经链接了 TableView,将委托和数据源设置为 self,并且 TableView 显示了项目的标题(Hurrah)但是当被触摸时,不会去 DetailController?我使用 NSLog 来确定哪个部分不起作用,当然还有 didSelectRowAtIndexPath 方法……这是我的代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *theItem = [items objectAtIndex:indexPath.row];
DetailController *nextController = [[DetailController alloc] initWithItem:theItem];
[self.navigationController pushViewController:nextController animated:YES];
[nextController release];
}
TableViewCell 只是突出显示蓝色并且没有链接到 DetailController。
提前致谢!
【问题讨论】:
-
您是否正确设置了导航控制器?
-
是的,完全连接起来了。 dataSource 和 delegate 都是 self
-
导航控制器不需要数据源和委托,视图控制器是否在 UINavigationController 中具有表视图?把它放在你的 didSelect 方法中:
NSLog(@"Navigation Controller: %@", self.navigationController);
标签: iphone xcode tableview viewcontroller