viewDidLoad in iOS 6 called once?

旧城冷巷雨未停 提交于 2019-11-30 23:56:07

问题


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.

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.

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?


回答1:


As of iOS 6, your UIViewController subclass will only receive viewDidLoad once, unless you write code to set its view back to 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.



来源:https://stackoverflow.com/questions/13152304/viewdidload-in-ios-6-called-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!