如何使用 UITableView 在 UITableViewCell 中显示视图控制器

How to show view controller in UITableViewCell with UITableView

我有带 tableView 的 UITableViewCell,如果用户 select 在我的单元格中,我需要显示新的控制器。但是,navigationControllerUIStoryboard 不起作用!我该怎么做?

我想你想问的是在你点击一个 UITableViewCell 之后,一个新的 UIViewController 会被推入。为此,你需要首先嵌入一个 navigationController 来创建一个推送视图控制器的堆栈。然后,在 tableView:didSelectRowAtIndexPath 内:添加:

    YourController *yourController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([YourControllerStoryboardId class])];
    [self.navigationController pushViewController:yourController animated:YES];

检查您是否设置了 UITableView 的委托。清理并 运行 您的代码。