[英]Can't push my view controller when I select a table view cell
I'm using Objective-C. 我正在使用Objective-C。 I want to push a new vier controller when I select a table view cell.
选择表格视图单元格时,我想推送一个新的vier控制器。 This is my code:
这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detailViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"detailVC"];
//something
[self.navigationController pushViewController:vc animated:YES];
}
I have a detail view controller in my storyBoard and set its storyboard ID "deatilVC". 我的StoryBoard中有一个详细视图控制器,并将其故事板ID设置为“ deatilVC”。 But when I select a table view cell, the simulator freezes.
但是,当我选择一个表格视图单元格时,模拟器就会冻结。 Someone can help me?
有人可以帮我吗?
Take one navigation controller and make the current controller from where your didSelectRowAtIndexPath will call to it's root controller in storyboard. 拿一个导航控制器,将当前的控制器从您的didSelectRowAtIndexPath调用到故事板中的根控制器。 Check the following example.
检查以下示例。
And then drag with right click of mouse to your current controller and make it "root view controller" just like below: 然后用鼠标右键单击拖动到您的当前控制器,并将其设置为“ root view controller”,如下所示:
Build and run your app. 生成并运行您的应用程序。
确保“ self.navigationController”不是零,“ vc”不是零
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.