开发者

UIKit: View controllers loading nib files automatically

开发者 https://www.devze.com 2023-03-20 06:21 出处:网络
It seems like since recent 开发者_JAVA百科times, view controllers automatically load a nib file with the exact name if one exists.

It seems like since recent 开发者_JAVA百科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.


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消