我的问题是我想在单击 VC3 上的任何按钮时显示 VC1。这是我的代码
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("registerNavigation")
self.presentViewController(vc, animated: false, completion: nil)
但我收到此警告“警告:尝试显示其 View 不在窗口层次结构中的 ViewController”,但没有任何反应。请告诉我,我做错了什么?
最佳答案
如果您想从 VC3 显示 VC1,则无需再次显示它,因为它已经加载到导航堆栈中。您只需要从导航堆栈中dismiss or pop
VC3 和VC2。如果您已提交它,则将其关闭;如果您已将其推送,则将其弹出。
您的警告的含义:您正在尝试呈现导航 Controller 1 的 View 层次结构中的内容,但不在导航 Controller 2 的 View 层次结构中。!!
希望这会有所帮助:)
关于ios - 当我尝试呈现 View 时收到此警告 "attempt to present ViewController whose view is not in the window hierarchy",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37384831/