When a view controller is created and displayed on the screen. Order of execution of code
1, Alloc create objects, allocate space
2. Init (Initwithnibname) initializes the object, initializes the data
3, Loadview from the nib load view, usually this step does not need to interfere. Unless you're not using the Xib file to create a view
4, Viewdidload loading complete, can be customized data and dynamic creation of other controls
5, Viewwillappear View will appear before the screen, the view will be displayed on the screen immediately
6, Viewdidappear view has been rendered on the screen completed
When a view is removed from the screen and the execution order is destroyed, the order is almost the opposite of the above
1. Viewwilldisappear view will be removed from the screen before execution
2, Viewdiddisappear view has been removed from the screen, the user can not see this view
3. Dealloc view is destroyed, you need to release the objects you created in Init and viewdidload
Uiviewcontroller life cycle and iOS program execution sequence