MPMoviePlayerViewController |允许横向模式 [英] MPMoviePlayerViewController | Allow landscape mode

查看:111
本文介绍了MPMoviePlayerViewController |允许横向模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用中流式传输视频。我发现的方法是:

I'm trying to stream a video in my app. The method I've found is :

NSURL *theMovieURL = [NSURL URLWithString:self.data.trailer];
        if (theMovieURL)
        {
            self.movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:theMovieURL];
            [self presentMoviePlayerViewControllerAnimated:self.movieController];
            [self.movieController.moviePlayer play];
        }

我不确定它是否是最传统的,但它确实有效。

I'm not sure if it's the most conventional, but it works.

问题是我无法弄清楚如何仅为视频设置横向模式。我应该使用像 shouldAutorotate shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation ,以及如何使用?

The problem is that I can't figure out how to allow the landscape mode, for the video only. Should I use something like shouldAutorotate or shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation , and how ?

仅供参考,整个应用程序仅允许纵向模式。

FYI, the entire app allows only the portrait mode.

感谢您的帮助。

推荐答案

shouldAutoRotate 从iOS 6开始被弃用,除非你想要< 6。

shouldAutoRotate is deprecated as of iOS 6 and should be avoided unless you're going for < 6 .

相反,你想要覆盖 supportedInterfaceOrientations preferredInterfaceOrientationForPresentation 方法。

Instead, you'd want to override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods.

在这种情况下,如果您不想为媒体播放器创建子类,则可以覆盖app委托中的方法,如下所示: / p>

In this case, if you don't want to subclass the media player you could override a method in the app delegate like so:

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]])
    {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    else
    {
        return UIInterfaceOrientationMaskPortrait;
    }
}

这篇关于MPMoviePlayerViewController |允许横向模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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