MPMoviePlayerController全屏旋转,而父视图控制器仅支持纵向方向 [英] MPMoviePlayerController rotating in full screen while the parent View Controller only supports portrait orientation

查看:122
本文介绍了MPMoviePlayerController全屏旋转,而父视图控制器仅支持纵向方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题只是我问题的一部分。我正在为我现有的应用程序实现iOS6轮换和方向支持。

this question is only one part of my problem. I am implementing iOS6 rotation and orientation support for my existing application.

所以我有一个ViewController,它包含一个嵌入在ViewController视图中的MPMoviePlayerController(我的应用程序需要它)。用户可以播放视频并在嵌入视图中查看,或使用默认播放器控件单击全屏按钮,播放器进入全屏模式。

So I have a ViewController that contains a MPMoviePlayerController embedded in ViewController view ( my application requires it ). User can play the video and see it in the embedded view or click on full screen button using the default player controls and player goes to full screen mode.

现在我已经将视图控制器限制为仅使用iOS6提供的新旋转API支持纵向方向。

Now I have restricted the view controller to only support portrait orientation using the new rotation APIs provided by iOS6.

// New Autorotation support.
- (BOOL)shouldAutorotate;
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

这非常有效。 ViewController仅支持纵向和用户在嵌入视图中播放影片。

this works pretty well. the ViewController only supports portrait and user play the movie in embedded view.

现在问题来了,当用户进入全屏模式时。在全屏模式下,当我旋转模拟器/设备时,电影将继续旋转。当我在全屏模式下播放电影时,在 shouldAutorotate supportedInterfaceOrientations 中的断点播放时,它仍会出现这两种方法分别返回 NO UIInterfaceOrientationMaskPortrait ,但电影仍在旋转......

Now the problem comes, when User goes into full screen mode. In full screen mode, the movie is keep on rotating, when i rotate the simulator/device. When i rotate the device while movie being played in full screen mode with breakpoints in shouldAutorotate and supportedInterfaceOrientations , it still comes in these both methods which return NO and UIInterfaceOrientationMaskPortrait respectively, but still the movie is rotating ...

为什么会这样? ....这是我的问题的一部分......第二部分是我希望当用户进入全屏模式时电影以横向模式进入。我希望电影播放器​​锁定横向模式,直到用户按下DONE按钮。

Why is this happening? .... this is one part of my question ... the 2nd part is I want the movie to enter in landscape mode when the user goes to full-screen mode. and I want the movie player to lock in landscape mode until user presses the DONE button.

请帮助....

推荐答案

你可以在下面试试函数在 AppDelegate

you can try below function in AppDelegate:

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{

}

你可以为这两种模式制定条件。

you can make condition here for both mode.

如果媒体播放器全屏显示那么

such as if media player is in full screen then

返回UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;

否则返回UIInterfaceOrientationMaskPortrait;

我还没试过,但我想,它应该适用于你的情况。

i have not tried it but i think, it should work in your case.

谢谢

这篇关于MPMoviePlayerController全屏旋转,而父视图控制器仅支持纵向方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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