What are the differences between didFinishLaunchingWithOption and viewDidLoad

喜夏-厌秋 提交于 2019-12-09 18:03:25

问题


What is the difference between the two methods didFinishLaunchingWithOption and viewDidLoad?

The former is a method of AppDlegate.m and the latter is a method of ViewController.m, but both of them perform the same mission of loading the UIs onto the view.


回答1:


The application:didFinishLaunchingWithOptions: is a UIApplicationDelegate protocol method that gets called when iOS has finished setting up an area for your App to run and is the insertion point for you, the developer, to load a view controller, etc.

The viewDidLoad method on the other hand is a method of the UIViewController class that gets called when an instance of UIViewController gets its view loaded into memory. From Apple's documentation:

Called after the controller’s view is loaded into memory.

Discussion This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.



来源:https://stackoverflow.com/questions/13053230/what-are-the-differences-between-didfinishlaunchingwithoption-and-viewdidload

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