iphoneloadview

Will loadView be called if there is a nib file?


If I override the loadView method, loadView will be called whether there is a nib file. If I don't override loadView and there is a nib file, will it be called ?


Solution

  • Yes, loadView is responsible for loading nib files automatically from known bundles based on the class name of the view controller. If you override loadView and don't call [super loadView], no nibs will be loaded. The UIViewController class will call loadView when its view property is called and is nil.

    Also note that overriding loadView and calling super is most likely not what you want. loadView is for setting the self.view property, that's it. Everything else should happen in viewDidLoad etc.