iOS 6中的viewDidLoad调用一次? [英] viewDidLoad in iOS 6 called once?

查看:117
本文介绍了iOS 6中的viewDidLoad调用一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抬头:此问题与最近的弃用 viewDidUnload 。我已经看到围绕这个主题的精彩和逻辑答案,但显然他们被证明是错误的。请谨慎行事,如您所见,这个话题非常混乱。

Head's up: This question is related to the recent deprecation of viewDidUnload. I have seen "great" and logical answers around this topic, but apparently they were proven wrong. Proceed with caution, this topic is very confusing as you see.

来自Apple的文档:


但是,当视图未附加到窗口时,系统会自动释放这些昂贵的资源
。大多数视图使用的剩余内存
足够小,以至于
系统自动清除并重新创建视图层次结构是不值得的。

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的视图显式设置为nil(手动卸载), viewDidLoad 只会在应用程序的整个生命周期内为任何已分配的viewController实例调用一次吗?

So... Can I safely assume in iOS 6 that, as long as I don't explicitly set the viewController's view to nil (unload it manually), viewDidLoad will only be called only once for any allocated viewController instance throughout the lifetime of the application?

推荐答案

As iOS 6中,您的 UIViewController 子类只会收到 viewDidLoad 一次,除非您编写代码来设置其查看返回 nil

As of iOS 6, your UIViewController subclass will only receive viewDidLoad once, unless you write code to set its view back to nil.

但是,我不会依赖复杂系统提供的视图控制器中的行为,如 UIImagePickerController 。也许它将自己的视图设置为nil。

However, I wouldn't rely on that behavior in a complex system-provided view controller like UIImagePickerController. Perhaps it sets its own view back to nil.

这篇关于iOS 6中的viewDidLoad调用一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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