gpt4 book ai didi

ios - isMovingToParentViewController 总是为导航堆栈的 Root View Controller 返回 FALSE?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:06:42 24 4
gpt4 key购买 nike

确定导航堆栈的 Root View (顶层) Controller 是作为最初呈现还是未被发现的结果出现的正确方法是什么?

iOS 文档建议在 viewWill/DidAppear: 中使用 isMovingToParentViewController: 来做出决定。这适用于压入堆栈的 View Controller ,但似乎总是为堆栈 Root View Controller 返回 FALSE。

感谢您的帮助。

最佳答案

看起来其他人已经回答了同样的问题:iOS: isMovingToParentViewController is not working as expected .

虽然它不完全正确,但我认为,因为 viewDidLoad 可能被调用不止一次,即使对于 Root View 也是如此。由于内存原因,它可能会被卸载,并且当它的 subview 从导航堆栈中弹出时需要重新加载。

如果您真的只想看到根 Controller 被添加一次,我会更改链接帖子中的解决方案以使用 static 变量而不是实例变量。

关于ios - isMovingToParentViewController 总是为导航堆栈的 Root View Controller 返回 FALSE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22777796/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com