Question

when overriding the loadView method in UIViewController, should one call [super loadView] in the beginning of the method or at the end of the method? And why?

Was it helpful?

Solution

Just to be really sure, you didn't mean viewDidLoad, right? Because they are two very different methods... as of 3.0, the docs reccomend always calling viewDidLoad at the start.

You can call it either before or after, but usually it is placed at the end unless you have a reason to do otherwise.

OTHER TIPS

According to the UIViewController class reference, you should not call [super loadView] at all:

Your custom implementation of this method should not call super.

Normally you should not call loadView directly. It merely sets your self.view property and is called by the view controller only.
You should call [super loadView] only if you need the view created by your super class, because you want to include it in your decoration view hierarchy or something like that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top