Force popover on iPhone with programmatically created UIPopoverPresentationController

后端 未结 2 1682
误落风尘
误落风尘 2021-02-07 10:30

I need to create a new popover view as the anchor is not visible in Interface Builder during compile time.

According to this post, implementing the delegate method will

相关标签:
2条回答
  • 2021-02-07 11:15

    It seems moving the line presentViewController(contentView, animated: true, completion: nil) to the end of the function would fix the issue.

    0 讨论(0)
  • 2021-02-07 11:15
    let contentView  = 
    PLMainNavigationManager.sharedInstance.storyboard.instantiateViewControllerWithIdentifier("PLSearchVCID") as! PLSearchVC
            contentView.modalPresentationStyle = UIModalPresentationStyle.Popover
            contentView.preferredContentSize = CGSizeMake(400.0, 500.0)
            var _popoverPresentationController = contentView.popoverPresentationController!
            _popoverPresentationController.delegate = self
            _popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.Any
            _popoverPresentationController.sourceView = self.view
           _popoverPresentationController.sourceRect = CGRectMake(-30, -280, 320, 400)  
            PLMainNavigationManager.sharedInstance.navigationController?.presentViewController(contentView, animated: true, completion: nil)
    
    0 讨论(0)
提交回复
热议问题