无法显示表格详细信息
我发誓我已经看了六个教程,但我不知道我做错了什么。我有一个通过 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
pushViewController:animated:
不做任何事情,你的navigationController
可能是nil
,但除此之外它肯定应该工作,因为UIViewController发送到
实例将显示某种视觉变化(除非视图相同并且您不使用动画)。尝试将pushViewController:animated:
的NSLog(@"blah");
行添加到您的didSelectRowAtIndexPath:
实现中,以确保它被调用。或者在该方法中设置断点。一堆
nil
就可以了。如果未找到.xib
,那么您将收到相应的调试消息,因此它正在查找.xib
。.xib
甚至还设置了有效的view
插座,因为如果您加载.xib
但没有view
,应用程序就会崩溃> 插座已设置。If
pushViewController:animated:
doesn't do anything, yournavigationController
could benil
, but otherwise it should definitely work since aUIViewController
instance sent topushViewController:animated:
will show some sort of visual change (unless the views are identical and you don't use animation). Try adding anNSLog(@"blah");
line to yourdidSelectRowAtIndexPath:
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 validview
outlet set since the app crashes if you load a.xib
but noview
outlet is set.