gpt4 book ai didi

ios - Objective-c UIDocumentInteractionController 加载灰屏

转载 作者:行者123 更新时间:2023-11-28 21:00:40 25 4
gpt4 key购买 nike

我正在尝试像这样预览 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];

我得到的只是带有文件名的灰色屏幕。文件大小为5.5MB

我做错了什么?

这是我的委托(delegate)方法:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self.navigationController;
}

我在我的控制台日志中看到了这个

[Snapshotting] Snapshotting a view (0x108c80800,_UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. 2018-03-07 20:39:16.169613-0500SchedulingiPadApplication[417:61893] [default] Couldn't issue fileextension for url:file:///var/containers/Bundle/Application/23540D89-0841-4F12-A6A4-A2840D4076F4/SchedulingiPadApplication.app/FLW-0032%20Design%20Sketches.pdf

PreviewItem

当我呈现 documentInteractionController 时会发生这种情况

最佳答案

您需要使用 NSURL fileURLWithPath:,而不是 URLWithString:

更好的是,使用 NSBundle URLForResource:withExtension: 直接获取 NSURL

关于ios - Objective-c UIDocumentInteractionController 加载灰屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49163667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com