为什么我无法从 UITableView 单元格转至详细视图?

发布于 2024-12-19 15:41:50 字数 892 浏览 2 评论 0原文

这是我的代码......

- (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

生来就爱笑 2024-12-26 15:41:50

问题是您使用了推送转场,并且没有使用 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.

情绪 2024-12-26 15:41:50

如果您不需要以编程方式执行 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?

流云如水 2024-12-26 15:41:50

[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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文