Our app's device orientation is only portrait, but have one video player view which need to rotate to landscape and rotate back;
I try to use supportedInterfaceOrientationsForWindow method in AppDelegate, but it seems not work anymore?
Xcode 8.3.3, iOS 10.3.2, Deployment Targit is 8.0.
Need I paste the code?
If you're making use of the
window
method parameter, try usingself.window
instead. During rotation,window
is a_UIInteractiveHighlightEffectWindow
and might not be what you need.I have code in
supportedInterfaceOrientationsForWindow
that returns differentUIInterfaceOrientationMask
values depending on which view controller is visible. When finding the visible view controller on thewindow
method parameter during a segue from a portrait view controller to a landscape view controller, the visible view controller was always a genericUIViewController
class with no navigation controller, parent view controller, child view controllers, or subviews.When using
self.window
instead, the visible view controller was the one I expected (one of the view controllers that needed to be displayed in landscape).Here's an example of the difference between
window
andself.window
when the method is called during rotation: