Demos of ViewControllers (chapter 6) of the book "Programming iOS 9".
The sequence of a view controller’s view is obtained:
- When the view controller first decides that it needs its view, loadView is always called.
- If we override loadView, we supply and set the view in code, and we do not call super. Therefore the process of seeking a view comes to an end.
- If we don’t override loadView, UIViewController’s built-in default implementation of loadView is used. It is this default implementation of loadView that loads the view controller’s associated nib. That is why, if we do override loadView, we must not call super — that would cause us to get both behaviors!
- If the previous steps all fail — we don’t override loadView, and there is no associated nib — UIViewController’s default implementation of loadView creates a generic UIView.