I am using a popover view controller where I don't want the popover to cover the full screen (iOS 13). I was trying to use:
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
The method was being called but the popover displayed was always full screen, even though a smaller preferred content size was being specified. After a lot of time trying many different things I found that there is another method which has 2 parameters and used it:
func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .none
}
Using this method makes the popover screen be the specified size. Anybody have an idea why the second one would work and the first one won't. I have a couple other apps in which I am using the first one with no issues, what gives?!!
Due to the documentation: from iOS 8.3 we should use
to handle all trait changes. Where
If we do not implement this method in the delegate, UIKit calls the
method instead.
So I guess in your app you try to create an adaptive interface and access specific trait values using the UITraitCollection horizontalSizeClass, verticalSizeClass, displayScale, and userInterfaceIdiom properties. That is why you should implement adaptivePresentationStyle(for:traitCollection:).