MPMoviePlayerController全屏幕方向问题

我的应用程序只支持景观。 我已经添加了一个MPMoviePlayerController到我的视图控制器的视图。

当我按下全屏button时,它工作正常,只能在iOS 5以前的版本中使用横向旋转。但是,在iOS 5.0+中,它也支持纵向(仅当进入全屏模式时)。

我怎样才能防止在iOS 5.0及以上的肖像支持?

尝试inheritanceMPMoviePlayerViewController并重写shouldAutorotatoToInterfaceOrientation方法,以仅支持横向模式:

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { if((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) { return true; } else { return false; } } 

我这样解决了这个问题:创build自定义导航控制器什么支持2方向:UIInterfaceOrientationLandscapeLeft && UIInterfaceOrientationLandscapeRight

更多细节:1.创build自定义导航控制器

CustomNavigationController.h文件

 #import <UIKit/UIKit.h> @interface CustomNavigationController : UINavigationController -(CustomNavigationController*)initWithRootViewController:(UIViewController *)rootViewController; @end 

CustomNavigationController.m文件

 @implementation IORNavigationController -(CustomNavigationController*)initWithRootViewController:(UIViewController *)rootViewController { self = [super initWithRootViewController:rootViewController]; if (self) { } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrientation); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end 

2.在Appdelegate添加自我导航控制器

Appdelegate.h

 @property (nonatomic, retain) CustomNavigationController* navigationController; 

Appdelegate.m

 self.navigationController = [[[CustomNavigationController alloc] initWithRootViewController:start] autorelease]; self.navigationController.view.autoresizesSubviews = YES; window.rootViewController = self.navigationController; [self.navigationController setNavigationBarHidden:YES]; 

现在你有横向的两个方向和video的应用程序。