Raphael
Raphael

Reputation: 291

UIKit: View controllers loading nib files automatically

It seems like since recent times, view controllers automatically load a nib file with the exact name if one exists.

I can simply initialize a view controller like

[[[ViewController alloc] init] autorelease]

and then when pushing it onto a navigation controller or so, the nib gets loaded without me ever doing anything.

This works in my app except for one view controller and I fail to figure out why. All view controllers that do load their nibs automatically have probably been created in Xcode 4, while the only one where it doesn't work was propably created back in Xcode 3. Is there a hidden switch somewhere? I coulud not find anything in the file settings of the nib, the nib itself and nothing in the source code of the view controllers that could explain it.

Upvotes: 4

Views: 2200

Answers (3)

Jim
Jim

Reputation: 73966

iOS has a case-sensitive filesystem, so make sure the case matches.

Double-check that the nib is enabled for the target you are building.

Check you don't have a loadView method.

Check the default handling for the nibName property.

Upvotes: 7

Herbert Zhang
Herbert Zhang

Reputation: 9

The other thing is, you should not override the UIViewController if you want to load the nib file automatically.

Upvotes: 0

bshirley
bshirley

Reputation: 8357

Also check to see if the custom class you are calling init on does not implement init to do something other than calling itself with a nil nibName.

Upvotes: 0

Related Questions