2012-05-17 60 views
0

我的应用仅支持Landscape。我已经添加了一个MPMoviePlayerController到我的视图控制器的视图。MPMoviePlayerController全屏方向问题

当我按下全屏按钮时,它工作正常,它只会在iOS 5之前的iOS版本中旋转。但是,在iOS 5.0+中,它也支持肖像(仅在进入全屏模式时) 。

如何防止iOS 5.0及以上版本的人像支持?

回答

0

尝试继承MPMoviePlayerViewController和重写shouldAutorotatoToInterfaceOrientation方法只支持横向模式:

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

我正在使用MPMoviePlayerController。我尝试过使用MPMoviePlayerController的子类并重写shouldAutorotatoToInterfaceOrientation方法来仅支持横向。但没有使用 – username123456

+0

对于iOS 5.0,MPMoviePlayerController已过时。你现在应该使用MPMoviePlayerViewController(这是一个小小的不同,但注意''''''''''),并尝试从那里去。 – WendiKidd

0

因此,我解决了这个问题:创建自定义导航控制器哪些支持2方向: UIInterfaceOrientationLandscapeLeft & & UIInterfaceOrientationLandscapeRight

更多详细信息: 1.创建自定义导航控制器

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.In的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]; 

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

+0

不适用于ios 5 – Dilip