美文网首页
UIPopoverPresentationController使

UIPopoverPresentationController使

作者: coderpaul | 来源:发表于2015-12-10 15:27 被阅读3465次

    从iOS 8开始,苹果提出新的 UIPopoverPresentationController代替UIPopoverController。代码如下:

    //创建你需要显示的controller
    UIViewController *cityAlertViewController = [[UIViewController alloc] init]; 
    //这里自定义的view
    DLpopupView *popupView = [[DLpopupView alloc] initWithFrame:CGRectMake(0.0, 0.0, 
    [300, 91) andRestorationName:@“DCpopupView”]; 
    
    cityAlertViewController.view = popupView; 
    //设置modal类型
    cityAlertViewController.modalPresentationStyle = UIModalPresentationPopover; cityAlertViewController.preferredContentSize = CGSizeMake(300, 91); 
    //配置 UIPopoverPresentationController 
    UIPopoverPresentationController *cityErrorPopover = cityAlertViewController.popoverPresentationController; 
    //设置代理
    cityErrorPopover.delegate = self;
    //设置相关属性
      cityErrorPopover.sourceView = self.view;
    cityErrorPopover.sourceRect = button.frame; cityErrorPopover.permittedArrowDirections = 
    UIPopoverArrowDirectionUp; cityErrorPopover.backgroundColor = greenNormal;
    // pop跳转
    [self presentViewController:cityAlertViewController animated:YES completion:nil];
    

    相关文章

      网友评论

          本文标题:UIPopoverPresentationController使

          本文链接:https://www.haomeiwen.com/subject/youshttx.html