【问题标题】:UITableView inside a scroll, inside of a UINavigationController can't pushViewControllerUITableView 在滚动中,在 UINavigationController 内部不能 pushViewController
【发布时间】:2015-11-09 03:41:04
【问题描述】:
我有一个 UINavigationController。它有它的主视图控制器,它包含一个滚动视图,然后是其中的 2 个表视图和一个按钮。如果我在点击时将按钮设置为 pushViewController,则效果很好。如果我在 didSelectRow 上将任一表视图设置为 pushViewController,则不会发生任何事情。我通过让 tableViews 在点击时打印 self.navigationController 进行测试,并且打印为零,所以我知道由于某种原因它没有正确继承导航控制器。
这很快。我可以让这个工作正常,在 ObjC 中以完全相同的方式没问题。
【问题讨论】:
标签:
ios
swift
uitableview
uinavigationcontroller
【解决方案1】:
你可以覆盖tableview的功能
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let YourVC = YourViewController();
YourVC.data = self.data[indexPath.section][indexPath.row];
self.navigationController?.pushViewController(YourVC, animated: true);
}