2013-03-21 54 views
0

我有一個關於一個查詢方位和播放視頻,MPMoviePlayerViewController支持橫向的iOS 4.3到6.1

我的應用程序支持肖像模式,但是當我開始任何視頻將只運行橫向模式那麼當視頻完成之後自動進入肖像模式。

下面的代碼我使用

**MyMovieViewController.h** 

#import <MediaPlayer/MediaPlayer.h> 


@interface MyMovieViewController : MPMoviePlayerViewController 

@end 

**MyMovieViewController.m** 

@implementation MyMovieViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 

    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
} 

- (BOOL)shouldAutorotate 
{ 
    return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeRight; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
} 

@end 

但上面的代碼只能在iPhone 4.3的模擬器和我的應用程序支持4.3到6.1的工作。

所以請你能幫我一把。

+0

你能告訴你實際上你想要什麼?你只想要肖像模式或風景模式? – Kalyani 2013-03-21 04:30:04

+0

Apple在iOS6中更改了旋轉方法。您可能希望查看文檔以查看新的API方法並實施它們。 – bennythemink 2013-03-21 04:41:38

+0

我想要電影只播放風景模式。並且當電影完成觀看時像豎屏模式一樣呈現原始的方向。 – milanjansari 2013-03-21 07:00:10

回答

0
-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeRight; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
} 

這幾種方法只在設備處於橫向時返回YES。然後它不會支持肖像模式。

相關問題