initWithNibName

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值