1、storyboard中获取入口控制器和指定控制器
2、加载xib
storyboard绑定cell时,无需注册
1、当要自定义的时候就要自己绑定类了
// 获取storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryBoard" bundle:nil];
// 获取入口控制器(箭头所指)
UINavigationController *navi = [storyboard instantiateInitialViewController];
// 获取指定控制器
// UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"home"];
self.window.rootViewController = navi;
2、获取的view最后用masonry约束下, 因为NSBundle加载出来的是数组,而xib里面就一个view,所以最后用lastObject或firstObject都行
// 加载xib文件
UIView *view = [[[NSBundle mainBundle] loadNibNamed:@"myView" owner:nil options:nil] lastObject];
view.frame = CGRectMake(0, 20, self.view.frame.size.width, 200);
[self.view addSubview:view];