Xcode 如何移动到其他ViewController?
我想知道当你按下一个单元格时,如何使UITableView转到另一个ViewController。到目前为止,我有以下代码:Xcode 如何移动到其他ViewController?,xcode,xcode4.2,Xcode,Xcode4.2,我想知道当你按下一个单元格时,如何使UITableView转到另一个ViewController。到目前为止,我有以下代码: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { } } 事情是这样的: - (void)tableView:(UITableView *)tableView did
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
}
}
事情是这样的:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
SomeViewController *newController = [[SomeViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:newController animated:YES];
[newController release]; // leave this line out if using ARC
}
}
警告:只需键入上面的内容,而不查看任何文档——如果在您将自己的视图控制器类名替换为SomeViewController
后它无法编译,请查找拼写错误等
顺便说一句,关于这个主题有很多文档,还有很多例子。如果上面的代码片段不能解决您的问题,请看一看。您的问题非常基本,以至于无法回答,或者更确切地说,如果您不掌握一些基本的iOS概念,答案将毫无意义。我强烈建议您花几个小时浏览(免费)的视频 如果你是一名注册开发者,苹果也有许多来自WWDC的优秀视频,详细介绍了所涉及的基本设计模式。YouTube上也有一些不错的视频
当然,看看源代码——来自苹果、斯坦福德课程,或者这个网站上的许多优秀教程()+1非常好的答案,显示了极大的耐心。