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
- (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
相关文章推荐
- initWithNibName方法
- initWithNibName&initWithCoder &awakeFromNib&UIView常见属性方法
- initWithNibName、initWithCoder、awakeFromNib和 loadNibNamed详解
- loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder的用法
- 关于 initWithNibName 和 loadNibNamed 的区别和联系
- initWithNibName、initWithCoder、awakeFromNib和 loadNibNamed详解
- iOS Development: Proper Use of initWithNibName:bundle: Affects UITableViewController
- loadView、viewDidLoad、initWithCoder、initWithNibName、awakeFromNib的调用时间及用法
- What is the difference between initWithCoder:, initWithNibName:, and awakeFromNib?
- IOS loadView、viewDidLoad、initWithCoder、initWithNibName、awakeFromNib的用法
- loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder的用法
- loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder的用法
- [[MyViewController alloc] initWithNibName:nil bundle:nil]; 搜索 Nib 文件的规则及注意事项
- initWithNibName与viewDidLoad执行顺序
- initWithNibName 和 loadNibNamed 的区别
- initWithNibName,initWithCoder,initWithFrame
- loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder的用法
- initWithNibName/awakeFromNib/initWithCoder
- 关于 initWithNibName 和 loadNibNamed 的区别和联系
- initWithNibName与一般init的区别