UIViewController loadView method
whe开发者_如何学运维n 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?
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.
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.
精彩评论