I have a UIViewController
with a UIWebView
that will eventually play a video stream.
The whole app is made for portrait orientation only, but I'd like the video to play on landscape as well.
The furthest I could get was implement this method on the AppDelegate
:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [[window rootViewController] isMemberOfClass:[UIViewController class]] ?
UIInterfaceOrientationMaskAllButUpsideDown : // If current view is the player, allow landscape
UIInterfaceOrientationMaskPortrait; // Otherwise, portrait-only
}
Debugging the top-most view controller, I found out that when the video player appears it is a member of UIViewController
, and since my app does not display any other VC of that class (only subclasses), that would work.
It does allow me to rotate the video (and only the video), what is great, but when I close the video and the app returns to the previous VC, the navigation bar breaks: instead of having the regular 64 pt height (20 from the status bar + 44 of the navbar itself), the status bar portion goes way and the bar will be 44 pt tall only:
How can I improve this solution and make it work perfectly?