yageek
yageek

Reputation: 4455

UIViewController default's behavior without XIB and without overriding loadView - documentation?

I was wondering what was the behavior of the UIViewController subclass when you use initWithNibName:bundle: with nil arguments without overriding loadView and without having a corresponding XIB or NIB file in the bundle.

With a simple program, I display the property self.view in the debugger :

(lldb) po self.view
 <UIView: 0x15e8b440; frame = (0 0; 320 548); autoresize = W+H; layer = <CALayer: 0x15e8a8b0>>

We can see that the class initialize a UIView whose frame has the same size as the UIScreen.bounds.

I did not find explanation in the Apple documentation. Is it explicitly documented somewhere ?

Upvotes: 1

Views: 1996

Answers (1)

iHunter
iHunter

Reputation: 6205

See the documentation for the loadView method:

If the view controller has an associated nib file, this method loads the view from the nib file. A view controller has an associated nib file if the nibName property returns a non-nil value, which occurs if the view controller was instantiated from a storyboard, if you explicitly assigned it a nib file using the initWithNibName:bundle: method, or if iOS finds a nib file in the app bundle with a name based on the view controller’s class name.

If the view controller does not have an associated nib file, this method creates a plain UIView object instead.

Upvotes: 3

Related Questions