无法显示表格详细信息

发布于 2024-12-27 17:32:31 字数 784 浏览 3 评论 0原文

我发誓我已经看了六个教​​程,但我不知道我做错了什么。我有一个通过 IB 嵌套在 UIView 中的表视图,并且该表的格式和填充都正确。我只是无法让它向我显示详细信息屏幕。表识别出点击,并且该行被选中,但是...该行保持选中状态。然后,绝对什么也不会发生。我可以选择具有相同结果的其他行,但除此之外什么都不会发生。我可以进出视图,并在整个应用程序中拥有完整的功能。我什至可以滚动表格视图,但我永远无法进入单元格详细信息屏幕。我已经在 IB 中将所有必要的部分链接在一起。

这是我的详细视图代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //Get the selected cell detail
    NSString *theString = [secondview objectAtIndex:indexPath.row];

    celldetails *dvController = [[celldetails alloc] initWithNibName:@"celldetails" bundle:nil];
    dvController.cellString = theString;

    [self.navigationController pushViewController:dvController animated:YES];
}

我尝试过“bundle:nil”和“bundle:[NSBundle mainBundle]”,但都没有产生所需的结果。有人有什么建议吗?

I swear I've looked at a half-dozen tutorials and I can't figure out what I'm doing incorrectly. I have a tableview nested within a UIView via IB, and the table both is formatted and populates correctly. I just can't get it to show me the details screen. The table recognizes the tap, and the row is selected, but... the row stays selected. Then, absolutely nothing happens. I can selected other rows with the same results, but nothing ever happens past that. I can move in and out of the view, and have full functionality throughout the entire app. I can even scroll the tableview, but I can never get into the cell detail screen. I've linked all the necessary pieces together in IB.

This is my code for the detail view:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //Get the selected cell detail
    NSString *theString = [secondview objectAtIndex:indexPath.row];

    celldetails *dvController = [[celldetails alloc] initWithNibName:@"celldetails" bundle:nil];
    dvController.cellString = theString;

    [self.navigationController pushViewController:dvController animated:YES];
}

I've tried both "bundle:nil" and "bundle:[NSBundle mainBundle]", but neither produces the desired result. Anyone have a word of advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

Bonjour°[大白 2025-01-03 17:32:31

如果 pushViewController:animated: 不做任何事情,你的 navigationController 可能是 nil,但除此之外它肯定应该工作,因为 UIViewController发送到 pushViewController:animated: 实例将显示某种视觉变化(除非视图相同并且您不使用动画)。尝试将 NSLog(@"blah"); 行添加到您的 didSelectRowAtIndexPath: 实现中,以确保它被调用。或者在该方法中设置断点。

一堆 nil 就可以了。如果未找到 .xib,那么您将收到相应的调试消息,因此它正在查找 .xib.xib 甚至还设置了有效的 view 插座,因为如果您加载 .xib 但没有 view,应用程序就会崩溃> 插座已设置。

If pushViewController:animated: doesn't do anything, your navigationController could be nil, but otherwise it should definitely work since a UIViewController instance sent to pushViewController:animated: will show some sort of visual change (unless the views are identical and you don't use animation). Try adding an NSLog(@"blah"); line to your didSelectRowAtIndexPath: implementation, just to be sure it's getting called. Or stick a breakpoint in that method.

A bundle of nil is fine. If the .xib was not found, then you'd get debug messages to that effect, so it's finding a .xib. The .xib even has a valid view outlet set since the app crashes if you load a .xib but no view outlet is set.

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