【问题标题】:How to show view controller in UITableViewCell with UITableView如何使用 UITableView 在 UITableViewCell 中显示视图控制器
【发布时间】:2016-09-17 10:12:45
【问题描述】:
我有带有tableView 的 UITableViewCell,如果用户在我的单元格中选择,我需要显示新的控制器。但是,navigationController 和 UIStoryboard 不起作用!我该怎么做?
【问题讨论】:
标签:
uitableview
uicollectionview
uistoryboard
uicollectionviewcell
【解决方案1】:
我想你想问的是在你点击 UITableViewCell 之后,一个新的 UIViewController 会被推入。为此,你需要首先嵌入一个 navigationController 来创建一个推送的视图控制器堆栈。然后,在 tableView:didSelectRowAtIndexPath: 里面添加这个:
YourController *yourController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([YourControllerStoryboardId class])];
[self.navigationController pushViewController:yourController animated:YES];
检查您是否设置了 UITableView 的委托。清理并运行您的代码。