ios10,ios9 中UIPopoverController

在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;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容