为什么我无法从 UITableView 单元格转至详细视图?
这是我的代码......
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[self performSegueWithIdentifier:@"BowlerDetail" sender:self];
}
我得到的回报是单元格仍然被选中,并且我的详细视图没有显示。是的,我已经查过了,“BowlerDetail”是 Segue 的名称。我收到的错误消息是 - 'NSInternalInconsistencyException',原因:'-[UITableViewController loadView] 加载了“tc8-Hk-kaK-view-YJA-Me-wti”笔尖,但没有获得 UITableView。'。
任何帮助表示赞赏。
编辑:在 xCode 4.2 之前的日子里,这就是我之前实现这里目标的方式。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
DetailView *detailVC = [[DetailView alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:detailVC animated:YES];
[detailVC release];
}
Here is my code.....
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[self performSegueWithIdentifier:@"BowlerDetail" sender:self];
}
All I get in return is that the cell is still selected, and my detail view does not show up. Yes, I have checked, and "BowlerDetail" is the name of the segue. The error message I get is - 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "tc8-Hk-kaK-view-YJA-Me-wti" nib but didn't get a UITableView.'.
Any help is appreciated.
Edit: In the pre-xCode 4.2 days, this is how I previously achieved the objective here.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
DetailView *detailVC = [[DetailView alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:detailVC animated:YES];
[detailVC release];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是您使用了推送转场,并且没有使用 UINavigationController 作为根视图控制器。因此,添加 UINavigationController 作为根视图控制器或将转场更改为模态。
The problem is that you used a push segue and you didn't use a UINavigationController as a root view controller.So add a UINavigationController as a root view Controller or change the segue to modal.
如果您不需要以编程方式执行 Segue,则可以通过按住 Option 键单击单元格并将“Modal”segue 拖动到要呈现的视图来连接 IB 中的单元格原型。
和你的代码?此方法是否位于启动 Segue 时可见的视图内?两个视图都在情节提要中吗?
If you do not need to perform a segue programatically, you can connect your cell's prototype in IB by option-clicking the cell and dragging the "Modal" segue to the view you want to present.
And with your code? Is this method inside the view that is visible when starting a segue? Are both views in storyboard?
[tableView deselectRowAtIndexPath:indexPathAnimated:NO];
。您从自身调用此方法。那是你想要的吗?我认为你应该删除这个。[tableView deselectRowAtIndexPath:indexPath animated:NO];
. You calling this method from itself. is that you whant? i think you should remove this.