LoadView UIViewController Method

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

+3
source share
3 answers

Just to be sure, you didn't mean viewDidLoad, right? Since they are two very different methods ... since version 3.0, docs recommends always calling viewDidLoad at the beginning.

You can call it before or after, but usually it is placed at the end, if you have no reason for this.

0
source

According to the UIViewController class reference, you shouldn't call [super loadView]at all:

.

+15

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

+7
source

Source: https://habr.com/ru/post/1720955/


All Articles