[英]How to push a new viewController when clicking on a tableView cell?
I thought that I had this code correct;我以为我的代码是正确的; however, when I run it, I click on the cell and nothing happens.然而,当我运行它时,我点击了单元格,但没有任何反应。 The code that I have to push the view controller is in my didSelectRowAt func.我必须推送视图控制器的代码在我的 didSelectRowAt 函数中。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let vc = ChatViewController()
vc.title = "Jenny Smith"
vc.navigationItem.largeTitleDisplayMode = .never
navigationController?.pushViewController(vc, animated: true)
}
Can anyone explain what I'm doing wrong here and why a click doesn't show a new ViewController?谁能解释一下我在这里做错了什么以及为什么单击不显示新的 ViewController?
You must try this to solve the problem, if there is any issues else you can ask me你必须尝试这个来解决问题,如果还有其他问题你可以问我
let VC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ChatViewController") as! ChatViewController
self.navigationController?.pushViewController(VC, animated: false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.