1、创建UIViewController时,自动重写以下初始化方法:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
2、实例化UIViewController时,如果使用xib文件,使用上面的方法直接实例化,例如:
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"MyXib" bundle:nil];
如果不使用xib文件,直接使用init方法实例化,例如:
MyViewController *vc = [[MyViewController alloc] init];
3、不管使用哪种方法进行实例化,都会执行创建时重写的initWithNibName方法。
【原文:http://hi.baidu.com/h3g2010/item/93053ad54f20ff37e3108f3e】