I'm writing a custom modal presentation using iOS 8's UIPresentationController. The controller being presented has a preferred interface orientation UIInterfaceOrientationLandscapeLeft.
Upon presentation of this controller with a UIPresentationController, it is shown in portrait, ignoring the result of the presented controller's preferredInterfaceOrientationForPresentation method.
Presenting View Controller
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let controller = segue.destinationViewController as? UIViewController {
controller.modalPresentationStyle = .Custom
controller.transitioningDelegate = self
}
}
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return nil
}
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return nil
}
func presentationControllerForPresentedViewController(presented: UIViewController,
presentingViewController presenting: UIViewController!,
sourceViewController source: UIViewController) -> UIPresentationController? {
return UIPresentationController(presentedViewController: presented, presentingViewController: presenting)
}
Presented View Controller
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return .LandscapeLeft
}
Is it possible to have UIPresentationController take into account the result of the presented controller's preferredInterfaceOrientationForPresentation method?
I answered this on the Apple forums but in case someone stumbles upon this thread from Google..
This is not expected to work. As far as I can tell, the logic to handle the orientation adjustment at presentation time exists only in the private UIPresentationController subclasses used to implement the default presentation styles.
As an aside, a custom presented view controller's -supportedInterfaceOrientations method is normally ignored unless you override -shouldRemovePresentersView in your presentation controller subclass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With