2012-05-17 85 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