Ios 显示页面时出现导航错误

Ios 显示页面时出现导航错误,ios,swift,uinavigationcontroller,Ios,Swift,Uinavigationcontroller,我在给斯威夫特编码 在我的代码的这一部分中,当选择表中的单元格时,它应该打开一个viewcontroller override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let next = self.storyboard?.instantiateViewController(withIdentifier: "SVC") self.navigationCont

我在给斯威夫特编码 在我的代码的这一部分中,当选择表中的单元格时,它应该打开一个viewcontroller

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {


    let next = self.storyboard?.instantiateViewController(withIdentifier: "SVC")
    self.navigationController?.pushViewController(next!, animated: true)
    self.present(next!, animated: true, completion: nil)

}
它返回一个错误

由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:“应用程序试图显示 主动控制器


当我运行它时,它工作正常,但当它打开特定的viewcontroller时,它会崩溃,屏幕冻结

您应该使用

self.navigationController?.pushViewController(next!, animated: true)
还是这个

 self.present(next!, animated: true, completion: nil)
编辑:使用此

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let next = self.storyboard?.instantiateViewController(withIdentifier: "SVC")
    self.navigationController?.pushViewController(next!, animated: true) 
}

第一个再次崩溃,第二个正常工作,但它没有显示所有导航控制器所代表的后退按钮!!当您将第一个代码放在崩溃所说的代码中时,您不能同时使用这两个代码,请附上您尝试的最后一个代码,返回func tableView(uu tableView:UITableView,didSelectRowAt indexPath:indexPath){let next=self.storyboard?.instanceeviewcontroller(带标识符:“SVC”)self.navigationController?.pushViewController(next!,动画:true)self.present(next!,动画:true,completion:nil)}您应该理解,两者都进行导航,但第一个显示在navigationController中这是唯一的区别,因此在self.present行中再次显示它会导致崩溃