MPMoviePlayerViewController支持iOS 4.3到6.1版本

时间:2013-03-21 03:54:06

标签: iphone landscape

我有一个关于方向和播放视频的查询,

我的应用程序支持纵向模式,但是当我启动任何视频时,它将仅以横向模式运行,然后在视频完成后自动进入纵向模式。

我正在使用的代码

**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。

所以,请你能帮助我。

1 个答案:

答案 0 :(得分:0)

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

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

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

当您的设备处于横向状态时,这些方法仅返回YES。然后它不支持肖像模式。