在ipad开发中,ios9中的UIPopoverController 运用的非常多,它继承的不是ViewController 而是NSObject,这就说它的显示依靠其他视图控制器,但是在ios10中它被废弃了用p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px STXinwei; color: #00afca}span.s1 {font-variant-ligatures: no-common-ligatures}
UIPopoverPresentationController替代,虽然可以使用作为程序员跟着Apple公司走是没错的,实现内容和显示大致如下:
QQ20161225-0.png
iOS9 初始化代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"PopContentController"];
UIPopoverController *popVc = [[UIPopoverController alloc] initWithContentViewController:controller];
[popVc presentPopoverFromBarButtonItem:self.leftButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
iOS10 的使用
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"PopContentController"];
controller.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:controller animated:YES completion:nil];
// configure the Popover presentation controller
UIPopoverPresentationController *popController = [controller popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
popController.barButtonItem = self.leftButton;
popController.delegate = self;