今天看视频,ios中怎样加载xx.xib视图,保存下来以备以后忘记,需要在didFinishLaunchingWithOptions方法中添加如下代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 开始添加
self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
[self.window makeKeyAndVisible];
//@后面的名字 就是xxx.xib文件的名字,例如;我的xxx.xib文件叫 View.xib
NSArray *views=[[NSBundle mainBundle]loadNibNamed:@"View" owner:self options:nil];
[self.window addSubview:[views lastObject]];
NSArray *views=[[NSBundle mainBundle]loadNibNamed:@"View" owner:self options:nil];
[self.window addSubview:[views lastObject]];
return YES;
}