推动视图控制器两次 [英] Pushing View Controller Twice

查看:127
本文介绍了推动视图控制器两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Within my app I'm having an issue with the following error:

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

这是一个来自少数用户的错误报告。我们试图复制它但不能(双击按钮等)。这是我们用来打开视图控制器的行:

It's a bug report that's comeback from a few users. We've tried to replicate it but can't (double tapping buttons etc). This is the line we use to open the view controller:

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上的大多数答案,因此对于如何调查而言有点不知所措。

Anybody have any ideas? I've done a bit of research and most answers on Stack we've covered so are at a bit of a loss for how to investigate.

推荐答案

试试这个以避免两次推送同一个VC:

Try this to avoid pushing the same VC twice:

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

这篇关于推动视图控制器两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆