美文网首页
IOS UIPopoverPresentationControl

IOS UIPopoverPresentationControl

作者: 透支未来 | 来源:发表于2017-09-28 15:45 被阅读10次

    从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];
    
    

    相关文章

      网友评论

          本文标题:IOS UIPopoverPresentationControl

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