如何在仅限肖像的应用程序中使用MPMovieViewController播放风景video

我的应用程序支持的界面方向是纵向和上下颠倒。 但是,当播放video时,我希望它能够播放全屏风景。 目前使用此代码,即使设备旋转,它也只播放肖像:

[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen]; player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; [self presentMoviePlayerViewControllerAnimated:player]; 

如何强制它进入横向模式?

我是这样做的:
在项目文件中,确保您支持横向方向 支持的界面方向
现在,在所有仍应为Portrait Only的ViewControllers中,添加此代码

 //ios6 - (BOOL)shouldAutorotate { return NO; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } //ios4 and ios5 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 

我已经输入了iOS5和iOS6两个调用,以便我的代码可以同时运行。

当您的MPMoviePlayerController视图变为全屏时,它将是一个新的ViewController,在其他所有内容之上。 因此,将允许根据项目的“支持的接口方向”进行旋转。 它不会看到你强迫其他ViewControllers进入Portrait的位置。