2

I have a view controller presented from a segue modally. Its presentation style is set to Form Sheet.

func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
    return .formSheet
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.presentationController?.delegate = self
}

On iPhone X and iPhone 8 Plus it works as expected, on iPhone Xs Max and Xr the width of the controller is respected, but the height is wieredly stretched. I have no way of confirming if this is simulator bug, iOS bug or expected behaviour as I don't have Xs Max myself. enter image description here

Zobia Kanwal
  • 4,085
  • 4
  • 15
  • 38
Sergey Kuleshov
  • 496
  • 4
  • 10

1 Answers1

0

Better use the modal presentation style overFullScreen for compact horizontal size clases and leave the formSheet for the horizontally regular ones.

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
    if controller.traitCollection.horizontalSizeClass == .regular {
        return .formSheet
    }
    return .overFullScreen
 }
rockdaswift
  • 9,613
  • 5
  • 40
  • 46