Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it ok to call [super loadView]?

I thought that I should never call [super loadView] but something is confusing me.

In description of loadView (UIViewController Class Reference) it is said that "Your custom implementation of this method should not call super.", but in ZoomingPDFViewer example that they gave, loadView implementation (ZoomingPDFViewerViewController) is calling [super loadView].

I have tried to call it from my loadView method and it works ok, but I just don't understand then what does it mean to not call super.

like image 769
Aleksa Avatar asked Mar 05 '12 15:03

Aleksa


People also ask

Should I call after my interview?

In this article, we discuss what to do and what to avoid when making a callback after an interview. Making a follow-up call after your interview can have several advantages, including: Picking up the phone and dialing your interviewer's number will likely take less time than drafting an email.

What if I don't have the interviewer's phone number?

If you do not have the interviewer's direct phone number, make sure to clearly state who you are trying to reach to avoid any confusion or misdirection. If a receptionist offers to take a message, politely decline and ask when your interviewer might be available to talk. You can then try to call them during that time to get them on the line.

Is it better to send a thank you email or phone call?

When you get ahold of them, you can briefly thank them for their time and reiterate your interest—no need to wait for an email response. While it is always thoughtful to send a thank you email or letter, a phone call adds an even more personal touch.

How to make the best impressions during a phone call?

To make the best impression during a call, make sure to take these steps: Introduce yourself clearly so the hiring manager knows which applicant you are. Mention something you discussed during the interview to help the hiring manager associate your call with your interview.


1 Answers

You definitely should not be calling [super loadView]. I'd say you found a bug in the ZoomingPDFViewer example.

You override loadView when you want to programatically create the view hierarchy for your view controller (not using a xib).

As you pointed out, the docs clearly state that you should not call super.

Your custom implementation of this method should not call super.

I assume this is to avoid loading both from a xib and programatically creating a view as this method is used by the base to load a view from a xib:

If the view controller has an associated nib file, this method loads the view from the nib file.

Note also that even if during allocation of your UIViewController object you pass nil for the nibNameOrNil parameter that the UIViewController implementation of loadView will try to load any xib with the associated class name in it.

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.

The real intent of this method is to give you full control of building the view hierarchy without relying on the built in xib loading mechanism.:

You can override this method in order to create your views manually.

Personally, I override loadView if: 1.) The xib I would make for it is really trivial or 2.) The layout of the control is very dynamic, so creating a xib with a static layout has little benefit.

like image 166
Sam Avatar answered Nov 10 '22 16:11

Sam