UIPresentationController
1> 管理所有Modal出来的控制器
2> 管理所有通过- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion方法显示出来的控制器
3> 管理\监听切换(切换的时刻)控制器的过程
4> presentingViewController:后面的控制器
5> presentedViewController:前面的控制器
6> presentedView:前面的控制器的view
UIPresentationController有两个非常重要的属性:
prentingViewController:源控制器
presentedViewCotroller:目标控制器
persetnedView:目标控制器的view
可以用这个几个属性实现切换动画。
管理控制器的切换的切换示例:
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
HMSecondViewController *second = [[HMSecondViewController alloc] init];
//Popover形式显示
// second.modalPresentationStyle = UIModalPresentationPopover;//一定先向设置<span style="font-family: Arial, Helvetica, sans-serif;">modalPresentationStyle,后面的</span><span style="font-family: Arial, Helvetica, sans-serif;">popoverPresentationController才生效</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">
</span>// second.popoverPresentationController.barButtonItem = self.navigationItem.leftBarButtonItem;//以popver显示在leftBarButtonItem下面
[self presentViewController:second animated:YES completion:nil];
NSLog(@"%@ %@", second.presentationController, second.popoverPresentationController);
}
// 1.只要调用了[self presentViewController:second animated:YES completion:nil];方法
// 2.首先会创建一个UIPresentationController
// 3.然后由UIPresentationController管理控制器的切换
@end