【发布时间】:2015-02-05 17:34:54
【问题描述】:
我有一个向用户显示文件(视频、pdf 文件和文档)的 iPhone 应用程序。当您单击 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;
}
有什么想法吗?我四处搜寻,但找不到任何有此特定问题的人。谢谢。
【问题讨论】:
标签: xcode ios8 orientation