如何在横向模式下显示MPMoviePlayerController [英] How to show MPMoviePlayerController in landscape mode

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

问题描述

我正在开发一个需要在横向和纵向模式下显示"MPMoviePlayerController"的应用程序.但是我的整个应用程序仅需要支持人像模式.除了"MPMoviePlayerController"以外,任何视图都不能使用横向模式.

i am working on a app where I am required to show "MPMoviePlayerController" in landscape mode and portrait mode. But My whole app is required to support Portrait mode only. That is no landscape mode for any view other than for the "MPMoviePlayerController".

我尝试了一些由于堆栈溢出而导致的问题.在我的情况下,没有任何效果.感觉卡在中间.但是我看到一些支持糟糕需求的应用程序. 我必须为iOS 6、7都实现它

I tried few things given over stack overflow. Nothing worked in my case. Feels Stuck in the middle. But I have seen some of the app supporting suck kind of requirements. I have to implement it for both iOS 6, 7

在我的应用中,我正在使用"XCDYouTubeVideoPlayerViewController"播放视频(播放youtube视频)

In my app am using "XCDYouTubeVideoPlayerViewController" for playing videos(playing the youtube videos)

请帮助

推荐答案

我对此有另一种解决方案,它将对所有MPMoviePlayerController都适用,下面是我的代码

I have another solution for this, It will work for all MPMoviePlayerController, below is my code

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

我们基本上要做的是为全屏显示的所有MPMoviePlayerController类(实际上是MPInlineVideoFullscreenViewController)启用横向显示.

What we basically do here is we enable Landscape orientation for all MPMoviePlayerController classes which are actually MPInlineVideoFullscreenViewController when you present it for fullscreen.

希望这对您有帮助

这篇关于如何在横向模式下显示MPMoviePlayerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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