UIPopoverPresentationController displaying popover as full screen

前端 未结 6 2058
小蘑菇
小蘑菇 2020-12-24 12:24

I am trying to use UIPopoverPresentationController to display a popover that doesn\'t take up the whole screen. I\'ve followed many different tutor

6条回答
  •  攒了一身酷
    2020-12-24 12:55

    iOS 12 / Swift 4

    There's also the possibility to show the popover on IPhone's as fullscreen and on IPad's as a popover.

    Just return .popover for adaptivePresentationStyle():

    func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
        return .popover
    }
    

    and set the popover-configuration like @mourodrigo did:

    dialog.modalPresentationStyle = .popover
    dialog.popoverPresentationController?.delegate = self
    dialog.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
    dialog.popoverPresentationController?.sourceView = view
    dialog.popoverPresentationController?.sourceRect = view.frame
    

提交回复
热议问题