gpt4 book ai didi

ios - 滚动内的 UITableView,UINavigationController 内不能 pushViewController

转载 作者:行者123 更新时间:2023-11-29 01:29:29 25 4
gpt4 key购买 nike

我有一个 UINavigationController。它有它的主视图 Controller ,它包含一个 ScrollView ,然后是其中的 2 个 TableView 和一个按钮。如果我将按钮设置为 pushViewController on tap,则效果很好。如果我将其中一个 TableView 设置为 didSelectRow 上的 pushViewController,则什么也不会发生。我通过让 tableViews 在点击时打印 self.navigationController 进行测试,结果打印为 nil,所以我知道出于某种原因它没有正确继承导航 Controller 。

这是在 swift 。我可以让这个工作正常,在 ObjC 中以完全相同的方式没问题。

最佳答案

你可以覆盖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);
}

关于ios - 滚动内的 UITableView,UINavigationController 内不能 pushViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33602196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com