先建立一个XIB文件,最好和viewController的类名相同,删除XIB固有的View,添加一个ViewController控件
关系的绑定file‘Owner和控件所属的类都要明确
初始化:在需要加XIB文件的ViewController的M文件,加入如下代码就OK了;
@implementation ChoosebuildingViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
return [[[NSBundle mainBundle] loadNibNamed:@"ChoosebuildingViewController"
owner:self
options:nil] firstObject];
}
return self;
}
为viewController加入XIB文件
时间: 2024-10-12 03:27:53