【问题标题】:MPMoviePlayerViewController Support landscape iOS 4.3 to 6.1MPMoviePlayerViewController 支持横向 iOS 4.3 到 6.1
【发布时间】:2013-03-10 11:16:51
【问题描述】:

我有一个关于方向和播放视频的疑问,

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

在我正在使用的代码下方

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

所以请你帮帮我。

【问题讨论】:

  • 你能说出你真正想要的是什么吗?你只想要纵向模式还是横向模式???
  • Apple 在 iOS6 中改变了他们的旋转方式。您可能希望查看文档以查看新的 API 方法并实现它们。
  • 我只想在横向模式下播放电影。并且当电影完成视图出现像纵向模式一样的原始方向。

标签: iphone landscape


【解决方案1】:
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

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

这几个方法仅在您的设备处于横向时返回 YES。然后它将不支持纵向模式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-01
    • 2013-02-09
    相关资源
    最近更新 更多