播放横向视频后出现纵向显示问题

Issue with portrait display after playing landscape video

我有一个 iPhone 应用程序可以向用户显示文件(视频、pdf 文件和文档)。当您单击我的 FileViewController 中的文件缩略图时,我调用 UIDocumentInteractionController 将文件呈现给用户。除文档控制器外,所有应用程序屏幕都锁定为纵向,可以旋转以查看横向。这在以前的版本中一切正常,但它突然发生变化和损坏,我推测是在 iOS 8 发布时。

现在,如果我播放视频并将其旋转为横向并点击完成,视频将从屏幕上删除,调用文档的 FileViewController nib 视图将在屏幕的一半处被切断。

我做了一些测试并打印出了视图边界的宽度和高度。在 iPhone 4S 上测试,当我第一次加载 FileViewController 时,宽度和高度是 320 x 480,正确。

当我以横向模式播放视频并点击完成时,底层视图会自动旋转回纵向,因为此视图不支持横向,但打印出屏幕边界时,宽度为 480,高度为 320 . 它仍然认为该应用程序是横向的,即使它已被移回纵向。屏幕本身是正圆的,刚好在320像素后截断!

我一直在尝试操纵各种控件的方向,但我看不出是什么导致了问题,更不用说修复它了。

这是我通过方向实现的方式:

应用程序已设置为支持所有方向。

我对标签栏控制器进行了子类化以指定以下内容:

- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

在 FileViewController 中,我调用了以下代码:

- (void) Show_File:(File *)file 
{
    NSURL *targetURL = [NSURL fileURLWithPath:filePath];

    UIDocumentInteractionController *document = [UIDocumentInteractionController interactionControllerWithURL: targetURL];
    document.delegate = self;

    [document presentPreviewAnimated: YES];
}

- (UIViewController *)documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
    AppDelegate *theDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];

    return theDelegate.fileNavController.childViewControllerForStatusBarHidden;
}

有什么想法吗?我四处搜索,但找不到遇到此特定问题的人。谢谢

对于遇到此问题的任何其他人,我向 Apple 提出了支持请求,显然这是一个 iOS 错误....

"This is a bug QLPreviewController (which is used by UIDocumentInteractionController to display previews)"

我有一个解决方法,目前工作正常。在我的 UITabBarController 子类中,我包含了这段代码:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

     if (self.transitionCoordinator && self.presentedViewController.presentationController {
        self.view.frame = self.presentedViewController.presentationController.containerView.bounds;
     }
}