在我的应用程序中,我遇到以下错误的问题:

Pushing the same view controller instance more than once is not supported

这是一个错误报告,受到了一些用户的欢迎。我们试图复制它,但是不能复制(双击按钮等)。这是我们用来打开视图控制器的行:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let editView = storyboard.instantiateViewControllerWithIdentifier("EditViewController") as! EditViewController
editView.passedImage = image
editView.navigationController?.setNavigationBarHidden(false, animated: false)
if !(self.navigationController!.topViewController! is EditViewController) {
   self.navigationController?.pushViewController(editView, animated: true)
}

有人有什么想法吗?我已经进行了一些研究,并且我们已经介绍了关于Stack的大多数答案,因此对于如何进行调查有些茫然。

最佳答案

尝试执行以下操作以避免两次推送同一VC:

if !(self.navigationController!.viewControllers.contains(editView)){
    self.navigationController?.pushViewController(editView, animated:true)
}

10-08 06:25