就我而言,我使用两个 View Controller VC1
和 VC2
。此处,VC1 按钮单击模态演示
和全屏
演示,并使用交叉溶解
过渡到演示 VC2。现在,从 VC2 关闭,然后我没有接到 VC1 viewWillAppear()
的调用。
我没有使用当前模型的代码库。我正在使用Storyboard Segue
。
为什么会发生这种情况以及如何解决这个问题?
最佳答案
来自Docs ,
Note
If a view controller is presented by a view controller inside of a popover, this method is not invoked on the presenting view controller after the presented controller is dismissed.
因此,根据文档,当 ViewController 以模态方式呈现另一个 ViewController 时,将不会调用此方法。要解决此问题,您需要使用
func dismiss(animated flag: Bool,
completion: (() -> Void)? = nil)
并将一些 viewWillLoad 逻辑移动(或重复)到完成处理程序。
关于ios - Swift 关闭当前 ViewController 后呈现 ViewController 不调用 viewWillAppear(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57973003/