- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
{
/*self = [super initWithNibName:nil
bundle:nil];*/
// Get a pointer to the application bundle object
NSBundle *appBundle = [NSBundle mainBundle];
self = [super initWithNibName:@"xxx"
bundle:appBundle];
if (self) {
...
}
return self;
}
以前一直不能理解 initWithNibName的参数是什么意思,这下理解了:
第一个参数 initWithNibName:xib文件的名称,如果传入nil,在系统自动会去找名称一样的xib文件
第二个参数 bundle:程序应该在哪个bundle目录下来找xib文件,传入nil,则会在app应用目录下找xib文件