Thereโs a bug in the ChallengeFinished project when you rotate a phone to horizontal while the popup is presented. You will get a full screen view with no Done button.
Youโre right. It seems when the device is rotated and the framework calls adaptivePresentationStyleForPresentationController(_:traitCollection:)
, the trait collection is the new one, with the compact height. But when it calls presentationController(_:viewControllerForAdaptivePresentationStyle:)
, the controller still has the old trait collection. I was able to solve this by adding a property to the view controller:
var presentingTraitCollection: UITraitCollection!
Then saving the last trait collection in adaptivePresentationStyleForPresentationController(_:traitCollection:)
:
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController,
traitCollection: UITraitCollection) -> UIModalPresentationStyle {
presentingTraitCollection = traitCollection
if traitCollection.verticalSizeClass == .Regular {
return .None
} else {
return .FullScreen
}
}
Then changing this line in presentationController(_:viewControllerForAdaptivePresentationStyle:)
from :
if adaptivePresentationStyleForPresentationController(controller, traitCollection: controller.traitCollection) == .None {
to:
if adaptivePresentationStyleForPresentationController(controller, traitCollection: presentingTraitCollection) == .None {