[英]Objective-c UIDocumentInteractionController loads gray screen
I am trying to preview a UIDocumentInteractionController like so: 我试图像这样预览UIDocumentInteractionController:
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"FLW-0032 Design Sketches" ofType:@"pdf"];
_previewItemURL = [NSURL URLWithString:filePath];
UIDocumentInteractionController *documentInteractionController =[UIDocumentInteractionController interactionControllerWithURL:_previewItemURL];
documentInteractionController.delegate = self;
[documentInteractionController presentPreviewAnimated:YES];
And all I get is the gray screen with the file name. 我得到的只是带有文件名的灰色屏幕。 The file is 5.5MB 该文件是5.5MB
What am I doing wrong? 我究竟做错了什么?
Here is my delegate method: 这是我的委托方法:
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self.navigationController;
}
I am seeing this in my console log 我在控制台日志中看到了这个
[Snapshotting] Snapshotting a view (0x108c80800, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. [快照]快照至少一次未渲染的视图(0x108c80800,_UIButtonBarStackView)需要afterScreenUpdates:YES。 2018-03-07 20:39:16.169613-0500 SchedulingiPadApplication[417:61893] [default] Couldn't issue file extension for url: file:///var/containers/Bundle/Application/23540D89-0841-4F12-A6A4-A2840D4076F4/SchedulingiPadApplication.app/FLW-0032%20Design%20Sketches.pdf 2018-03-07 20:39:16.169613-0500 SchedulingiPadApplication [417:61893] [默认]无法为url发出文件扩展名:file:/// var / containers / Bundle / Application / 23540D89-0841-4F12-A6A4 -A2840D4076F4 / SchedulingiPadApplication.app / FLW-0032%20Design%20Sketches.pdf
PreviewItem PreviewItem
This happens when I a presenting the documentInteractionController 当我提出documentInteractionController时会发生这种情况
You need to use NSURL fileURLWithPath:
, not URLWithString:
. 您需要使用NSURL fileURLWithPath:
而不是URLWithString:
NSURL fileURLWithPath:
Better yet, use NSBundle URLForResource:withExtension:
to get the NSURL
directly. 更好的是,使用NSBundle URLForResource:withExtension:
直接获取NSURL
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.