1.创建UIViewController
//通过代码创建UIViewController
UIViewController *viewCtl = [[UIViewController alloc]init]
//通过xib创建
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:
(NSBundle *)nibBundleOrNil
//通过storyBoard创建控制器
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITabBarController *tabBarController = [storyBoard instantiateViewControllerWithIdentifier:@"tabBar"];
[self presentViewController:tabBarController animated:YES completion:nil];
2.视图控制器的生命周期
加载视图
- (void)loadView
视图已经加载
- (void)viewDidLoad
视图即将出现
- (void)viewWillAppear:(BOOL)animated
视图已经出现
- (void)viewDidAppear:(BOOL)animated
视图即将消失
- (void)viewWillDisappear:(BOOL)animated
视图消失
- (void)viewDidDisappear:(BOOL)animated
3.模态视图跳转
//模态视图的出现
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^) (void))completion;
//通过模态视图跳转的场景一般是临时弹出的窗 ,譬如:登陆、注册的窗口
@property(nonatomic,assign) UIModalTransitionStyle modalTransitionStyle //修改模态视图跳转的动画效果
关闭对应模态视图跳转窗
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void(^)(void))completion
4.视图控制器之间的正向传值
1.属性传值 2.重写初始化方法传参