On my ipad, to set a custom form sheet size, I'm setting the preferred content size by tapping into the segue that presents it:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "SaleSegue" {
let horizontalPadding = 40
let verticalPadding = 30
let width = view.frame.size.width - CGFloat(horizontalPadding * 2)
let height = view.frame.size.height - CGFloat(verticalPadding * 2)
let navigationController: UINavigationController = (segue.destination as? UINavigationController)!
navigationController.preferredContentSize = CGSize(width: width, height: height)
}
}
And it works as expected, however, what I'm having trouble with is how to get the desired results when screen rotates. The fact that it doesn't leads me to believe this is the absolute wrong approach. I've tried overwriting preferredContentSize inside of the rootview controller of the navigation controller, however, the modal just begins to shrink as in, the width and height of its view is changing for some reason I don't understand.
My question is more so if anyone here has done this in the past and what's the proper way of achieving this?
I've attached a sample project outlining the issue:
h ttps://www.dropbox.com/s/6ik2p6bwg7962sz/Example.zip?dl=0