gpt4 book ai didi

ios - tableview 中的 Cell Click 不会快速导航到新 Controller

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

我的应用程序中有表格 View ,我想在表格 View 的单元格单击上推送一个新的 View Controller ,但它不起作用。

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
let section = indexPath.section
let controller : ProductInfoViewController = self.storyboard?.instantiateViewControllerWithIdentifier("ProductInfoViewController") as! ProductInfoViewController
controller.product = TableData[section]
self.navigationController?.pushViewController(controller, animated: true)
print("clicked section : \(section)")
// print(TableData[row])
}

有人知道我在这里犯了什么错误吗?我在 Storyboard 中有带有 ID 的正确 View Controller 。控制台中也没有错误。

最佳答案

如果您的 navigationController 为 nil,则您没有任何导航堆栈来插入 viewcontroller。看起来您正在使用 Storyboard,因此将此 Controller 嵌入到 navigationcontroller。为此,在 Storyboard中选择此 View Controller ,单击顶部菜单中的“编辑器”转到“嵌入”并选择导航 Controller ...希望对您有所帮助:)

关于ios - tableview 中的 Cell Click 不会快速导航到新 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37108046/

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