0

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?

tuoxie
  • 81
  • 4

1 Answers1

0

If you're making use of the window method parameter, try using self.window instead. During rotation, window is a _UIInteractiveHighlightEffectWindow and might not be what you need.

I have code in supportedInterfaceOrientationsForWindow that returns different UIInterfaceOrientationMask values depending on which view controller is visible. When finding the visible view controller on the window method parameter during a segue from a portrait view controller to a landscape view controller, the visible view controller was always a generic UIViewController 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 and self.window when the method is called during rotation:

(lldb) po window.debugDescription
"Optional(<_UIInteractiveHighlightEffectWindow: 0x106325960; frame = (0 0; 667 375); hidden = YES; gestureRecognizers = <NSArray: 0x1c4444a40>; layer = <UIWindowLayer: 0x1c4235c60>>)"

(lldb) po self.window.debugDescription
"Optional(<UIWindow: 0x106409840; frame = (0 0; 667 375); autoresize = W+H; gestureRecognizers = <NSArray: 0x1c0054c40>; animations = { position=<CABasicAnimation: 0x1c02323c0>; bounds.origin=<CABasicAnimation: 0x1c0232480>; bounds.size=<CABasicAnimation: 0x1c02324a0>; }; layer = <UIWindowLayer: 0x1c0223a00>>)"
Harrison Friia
  • 372
  • 2
  • 10