我正在使用 Objective-C。当我选择 TableView 单元格时,我想推送一个新的 vier Controller 。这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detailViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"detailVC"];
//something
[self.navigationController pushViewController:vc animated:YES];
}
我的 Storyboard中有一个详细 View Controller ,并将其 Storyboard ID 设置为“deatilVC”。但是当我选择 TableView 单元格时,模拟器会卡住。有人可以帮助我吗?
最佳答案
采用一个导航 Controller 并从 didSelectRowAtIndexPath 将调用它的 Storyboard中的根 Controller 的位置创建当前 Controller 。检查以下示例。
然后用鼠标右键单击拖动到您当前的 Controller 并使其成为“ Root View Controller ”,如下所示:
构建并运行您的应用。
关于ios - 选择表格 View 单元格时无法推送我的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33937918/