gpt4 book ai didi

ios - iOS 6 中的 viewDidLoad 调用一次?

转载 作者:技术小花猫 更新时间:2023-10-29 11:22:38 28 4
gpt4 key购买 nike

注意:这个问题与最近的 deprecation of viewDidUnload 有关。我已经看到 "great" and logical answers 围绕这个主题,但显然是 they were proven wrong 。请谨慎行事,如您所见,这个主题非常令人困惑。

From Apple's Docs:

However, the system automatically releases these expensive resources when the view is not attached to a window. The remaining memory used by most views is small enough that it is not worth it for the system to automatically purge and recreate the view hierarchy.

所以...我可以安全地假设在 iOS 6 中,只要我没有明确地将 viewController 的 View 设置为 nil(手动卸载它),viewDidLoad 将只被调用一次在应用程序的整个生命周期中为任何分配的 viewController 实例?

最佳答案

从 iOS 6 开始,您的 UIViewController 子类将只接收一次 viewDidLoad,除非您编写代码将其 view 设置回

但是,我不会在复杂的系统提供的 View Controller (如 UIImagePickerController)中依赖该行为。也许它将自己的 view 设置回 nil。

关于ios - iOS 6 中的 viewDidLoad 调用一次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13152304/

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