presentation Controllers的使用
presentation Controllers的使用
by 伍雪穎
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)show:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
TestViewController *contentViewController = [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([TestViewController class])];
contentViewController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *detailPopover = contentViewController.popoverPresentationController;
detailPopover.delegate = self;
detailPopover.barButtonItem = sender;
detailPopover.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:contentViewController animated:YES completion:nil];
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
- (UIViewController *)presentationController:(UIPresentationController *)controller viewControllerForAdaptivePresentationStyle:(UIModalPresentationStyle)style {
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller.presentedViewController];
return navController;
}