这个问题只是我问题的一部分。我正在为我现有的应用程序实现 iOS6 旋转和方向支持。
所以我有一个 ViewController,它包含一个嵌入在 ViewController View 中的 MPMoviePlayerController(我的应用程序需要它)。用户可以播放视频并在嵌入式 View 中查看它,或者使用默认播放器控件单击全屏按钮,然后播放器进入全屏模式。
现在我使用 iOS6 提供的新旋转 API 将 View Controller 限制为仅支持纵向。
// New Autorotation support.
- (BOOL)shouldAutorotate;
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
这很好用。 ViewController 仅支持纵向和用户在嵌入式 View 中播放电影。
现在问题来了,当用户进入全屏模式时。在全屏模式下,当我旋转模拟器/设备时,电影会继续旋转。当我在 shouldAutorotate
和 supportedInterfaceOrientations
中以全屏模式播放电影时旋转设备时,它仍然出现在这两种返回 NO
的方法中> 和 UIInterfaceOrientationMaskPortrait
,但影片仍在旋转......
为什么会这样? ....这是我的问题的一部分......第二部分是我希望当用户进入全屏模式时电影进入横向模式。我希望电影播放器锁定在横向模式,直到用户按下 DONE 按钮。
请帮忙....
最佳答案
您可以在 AppDelegate
中尝试以下功能:
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
}
你可以在这里为两种模式设置条件。
比如如果媒体播放器是全屏的话
返回 UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
否则返回UIInterfaceOrientationMaskPortrait;
我还没有尝试过,但我认为它应该适用于您的情况。
谢谢
关于iphone - MPMoviePlayerController 全屏旋转,而父 View Controller 仅支持纵向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13580753/