@interface ViewController ()<UIPopoverPresentationControllerDelegate, UIAdaptivePresentationControllerDelegate> @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; }
原文地址:http://blog.csdn.net/rainlesvio/article/details/41852909