I have an MPMoviePlayerViewController (a subclass, rather, XCDYouTubeVideoPlayerViewController), which I present with the following code
LPVideo *video = [_videos objectAtIndex: indexPath.row];
XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier: video.code];
[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController];
My problem is that while the entire application is locked in portrait mode, I still want the user to play the video in landscape orientation, so I added this to my AppDelegate
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]])
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
This works great, allowing the user to watch video in portrait orientation; however, if the video player is disabled in portrait mode, the presented view manager also switched to portrait, which I do not want to do.
, supportedInterfaceOrientations shouldAutorotate UINavigationController, .
, , , , , . , , .
"" viewWillAppear:animated, .
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *view = [window.subviews objectAtIndex:0];
[view removeFromSuperview];
[window addSubview:view];
[UIViewController attemptRotationToDeviceOrientation];
.