转场的方法
- push方法转场
- modal方法转场
- 自定义转场
//push方法转场
[self.navigationController pushViewController:[ZCResultViewController new] animated:YES];//push
[self.navigationController popViewControllerAnimated:YES];//返回
//modal方法转场
[self presentViewController:[ZCResultViewController new] animated:YES completion:nil];//present
[self dismissViewControllerAnimated:YES completion:nil];//返回
UIViewController状态
- (void)loadView {
[super loadView];
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidDisappear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
注意 : (loadView方法) If you use Interface Builder to create your views and initialize the view controller, you must not override this method.
转场过程对状态的影响
- 从firstVC转场到resultVC的过程,依次调用
- viewWillDisappear(firstVC)
- viewWillAppear (resultVC)
- viewDidDisappear (firstVC)
- viewDidAppear (resultVC)
- 从resultVC转场到firstVC的过程,依次调用
- viewWillDisappear(resultVC)
- viewWillAppear (firstVC)
- viewDidDisappear (resultVC)
- viewDidAppear (firstVC)
说明 : Disappear(Appear)过程无转场动画的情况下,Will和Did方法之间几乎是同时调用。在有转场动画的情况下,Will和Did方法的调用时间相差0.6秒左右