2013-03-21 85 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。然后它不会支持肖像模式。

相关问题