【发布时间】:2013-10-27 05:18:51
【问题描述】:
UIDocumentInteractionController 似乎无法与新的 iOS 7 状态栏正确交互,尤其是在横向时。我现在用于显示查看器的代码:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"example" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:filePath];
UIDocumentInteractionController *pdfViewer = [UIDocumentInteractionController interactionControllerWithURL:url];
[pdfViewer setDelegate:self];
[pdfViewer presentPreviewAnimated:YES];
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
return self.view;
}
当交互控制器首次出现时,状态栏与标题重叠。
在另一侧旋转到横向暂时修复了该行为。
正如预期的那样,点击文档本身可以关闭框架。但是,一旦再次点击文档以激活框架,就会再次发生重叠,就像第一张图像一样。
我尝试设置documentInteractionControllerRectForPreview 无济于事。
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height);
}
我不希望在交互控制器出现时隐藏状态栏,我认为可以正确执行此操作,因为 Mail 应用程序行为正确,并且看起来它使用的是同一个类。
为任何想使用代码的人附加一个最小的示例项目: https://hostr.co/PiluL1VSToVt
【问题讨论】:
-
这是 iOS 7 中的错误吗?有新的解决方案吗?我使用相同的方法来解决问题,但它导致了我的应用程序中的另一个错误。
标签: ios cocoa-touch ios7 statusbar uidocumentinteraction