Viewcontroller Load View
When loaded from the storyboards, the Initwithcode is invoked, and the Init is invoked if it does not exist. The Awakefromnib method is then invoked for each object inside.
In the case of alloc out of memory, the Init method is tuned.
Viewcontroller finds the view associated with it in the order that:
First, determine if the subclass overrides the Loadview if there is a direct call. The viewdidload is then tuned to complete the view loading.
If it is external by calling Initwithnibname:bundle to specify NIB filename, Viewcontroller records this nib to create view.
If the Initwithnibname:bundle name parameter is nil, Viewcontroller will find the nib associated with it through the following two steps.
If the class name contains controller, such as Viewcontroller's class name is Myviewcontroller, find whether there is a myview.nib;
Look for files like the Viewcontroller class name, such as Myviewcontroller, to find out if myviewcontroller.nib exists.
If the subclass does not have an overridden Loadview, Viewcontroller will look for or call its default loadview from Stroyboards, and the default Loadview return a blank UIView object.
Note the first step
The Viewcontroller is to determine whether the subclass overrides the Loadview, rather than to determine whether the Viewcontroller view is empty after calling the loadview of the child class. That is, if the subclass rewrites the Loadview, regardless of whether the subclass can get the View,viewcontroller in the Loadview, it will directly adjust viewdidload to complete the view loading.
Viewcontroller Life cycle function
Boot order
Initwithcoder
Call Init if it does not exist
Loadview//If you have rewritten it, it will be called here, and this step can be referenced below
Viewdidload
After the view has just been load and has been connected to the Iboutlet, this place needs to be put into the initialization to accomplish things. [View is not yet displayed]
Viewwillappear
Called when view is about to be displayed.
He is fit to do two things:
1. Load some expensive operations at the last minute
2. Modify Geometric features
Description
[Balabala] is written here if you need to adjust the geometry of the view [changes after rotation].
If it is a long time operation, it is best to open a ready-made operation here.
Viewwilllayoutsubviews
Upcoming
Viewdidlayoutsubviews
When the frame of the view's child view changes [For example: rotating the screen]
This method is often used [did] to handle the layout problems after rotation.
Viewdidappear
Just Show