iphone - MPMoviePlayerController 全屏旋转,而父 View Controller 仅支持纵向

标签 iphone objective-c ios ios6 mpmovieplayercontroller

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

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

现在我使用 iOS6 提供的新旋转 API 将 View Controller 限制为仅支持纵向。

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

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

这很好用。 ViewController 仅支持纵向和用户在嵌入式 View 中播放电影。

现在问题来了,当用户进入全屏模式时。在全屏模式下,当我旋转模拟器/设备时,电影会继续旋转。当我在 shouldAutorotatesupportedInterfaceOrientations 中以全屏模式播放电影时旋转设备时,它仍然出现在这两种返回 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/

相关文章:

iphone - iPhone开发语言

iphone - 更新数据库时程序卡住

objective-c - CGContextDrawImage 泄漏

ios - 无法取消选择 UITableView 中索引路径中的一行

iphone - iOS 应用角标(Badge)仍然存在

iphone - 使 View 看起来像推特应用程序对新推文所做的那样 (iPad)

ios - 共享扩展不显示数据 -- ios

ios - "repeated"类型字段未在 Google Protocol Buffer Objective C 中编译

ios - Swift:在 tableView 中搜索 JSON 数据

ios - 使用 FHSTwitterEngine 发布图像时出现错误