Master
One, the controller's various creation way
How to create a controller
Create with Storyboard
Note: Loading Uistoryboard simply loads the storyboard named Test, and does not create
Controllers and controls in the storyboard
Create with Xib
Note: In order for the view in Xib to be set to the view of the created controller, you must set the file ' s owner of Xib
The controller is created for. and file's owner right-click on the view to connect to the view in Xib.
Storyboard The above actions are done by default
Second, how to create the Controller view
1. Create without the same name Xib case
2. Create with Storyboard
3. Create with the specified Xib case
4. Create with the same name Xib case
5. Create a case with the same name without controll
6. Overriding the controller's Loadview method
First approach: Create without xib and storyboard cases
(Creating a controller from Alloc init automatically creates a blank view as the controller's view)
Second way: Create with Storyboard
If created through storyboard, it is based on the controller view described by the arrow pointing to the storyboard
Create a view of the controller
Third Way: Create with specified Xib (call Initwithnib: method to create Controller)
If created through Xib, the controller's view is created according to the controller view described in Xib
Fourth Way: Created with the same name as the controller xib (directly call the Init method to create the controller)
If you have the same name Xib, the view that is described in the same name Xib is automatically found as the controller
Fifth approach: Created with the same name as the controller (but without controller) Xib (call directly
Init method to create a controller)
If there is a xib with the same name as the controller (but without controller), the view of the xib is automatically found as the control
View of the system
Sixth way: Override the Loadview method of the controller (this method is typically used for custom controller view)
When to call Loadview will represent when the controller's view is loaded
If you override the controller's Loadview method, you will not be able to load a xib that has the same name removed controller
With the same name as the Xib, instead of creating a blank view (without writing anything) as a view of the controller,
You can also create a view directly in the Loadview
Third, the Controller view delay loading (lazy loading)
* The view of the controller is delayed loading: reload when used
* You can use the Isviewloaded method to determine whether a Uiviewcontroller view has been loaded
* The controller's view is loaded and will call Viewdidload
iOS Foundation-uikit Framework-Multiple controller management-creation of controller and controller view