MPMoviePlayerController在iPad中全屏怪癖 [英] MPMoviePlayerController fullscreen quirk in iPad

查看:140
本文介绍了MPMoviePlayerController在iPad中全屏怪癖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在视图控制器中显示MPMoviePlayerController,并让用户使用默认控件切换全屏,例如YouTube应用。我在一个简单的例子中使用以下代码:

I want to show a MPMoviePlayerController in a view controller and let the user toggle full screen with the default controls, like the YouTube app. I'm using the following code in a bare-bones example:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.player = [[MPMoviePlayerController alloc] init];
    self.player.contentURL = theURL;
    self.player.view.frame = self.viewForMovie.bounds;
    self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.viewForMovie addSubview:player.view];
    [self.player play];
}

这种情况很有效,直到用户全屏播放视频,旋转设备和点击屏幕。状态栏显示在错误的位置,如下面的屏幕截图所示。

This works well until the user makes the video full screen, rotates the device and taps on the screen. The status bar is shown in the wrong position, as shown in the screenshot below.

我正在使用模板Tab Bar Application for iPad。我只添加了上面的viewDidLoad,视图变量和XIB中的UIView来显示电影播放器​​。

I'm working with the template Tab Bar Application for iPad. I've only added the viewDidLoad above, the view variables and an UIView in the XIB to show the movie player.

我做错了什么?

推荐答案

是的,我也遇到了这个问题。它肯定似乎是MPMoviePlayerController本身的一个错误。

Yeah, I'm experiencing this problem as well. It definitely appears to be a bug in the MPMoviePlayerController itself.

我在我的应用程序中确定的解决方法是在退出全屏模式时自己更正状态栏:

The workaround I've settled on in my application is to just correct the status bar myself when I exit fullscreen mode:

- (void)playerDidExitFullscreen:(NSNotification *)notification {
    MPMoviePlayerController *moviePlayer = (MPMoviePlayerController *) notification.object;

    if (moviePlayer == self.player) {
        UIApplication *app = [UIApplication sharedApplication];
        if (app.statusBarOrientation != self.interfaceOrientation) {
            [app setStatusBarOrientation:self.interfaceOrientation animated:NO];
        }
    }
}

这不能解决问题在全屏模式下出现问题,但之后确实会修复它。

This doesn't fix the problem while in fullscreen mode, but it does fix it afterwards.

当然注意,该功能需要添加到通知中:

Note of course that the function needs to be added to the notification:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerDidExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];

这篇关于MPMoviePlayerController在iPad中全屏怪癖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆