您的位置:首页 > 其它

initWithNibName

2012-11-04 21:44 120 查看
The lifecycle starts with alloc and initialization of course

- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)aBundle;

Can I build a UIViewController ’s view in code (i.e. w/o a .xib)?

Yes.

If no .xib is found using mechanism above, UIViewController will call - (void)loadView on itself.

loadView ’s implementation MUST set the view property in the UIViewController .

Don’t implement loadView AND specify a .xib file (it’s undefined what this would mean). Stanford

This is UIViewController ’s d e s i g n at e d i n it i a l i z e r.

The UIViewController tries to get its view from the specified .xib file called nibName.

If nibName is nil , it uses the name of the class as the nibName ( HappinessViewController.xib).

The bundle allows you to specify one of a number of different .xib files (localization).

We’ll cover NSBundle later in the course when we talk about localization.

Passing nil for aBundle basically means “look in the Resources folder from Xcode.”

Initializing UIViewController with init is very common, it means nibName is nil & aBundle is ni
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: