我正在尝试将以下功能放入我正在编写的 iOS 应用程序中:
- 在 XCode 中的项目的资源文件夹中发送一组 PDF
- 将 PDF 复制到应用程序目录
- 在网络视图中打开 PDF。
据我所知,前两个步骤工作正常(我在复制操作后使用 FileManager 检查 fileExistsAtPath)。
但是,Web 视图是空的,并且出错(“请求的 URL 在服务器上不存在”)。
我的打开文件的代码如下:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *localDocumentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName = @"example.pdf";
NSString *localDocumentsDirectoryPdfFilePath = [localDocumentsDirectory
stringByAppendingPathComponent:pdfFileName];
pdfUrl = [NSURL fileURLWithPath:localDocumentsDirectoryPdfFilePath];
[webView loadRequest:[NSURLRequestWithURL:pdfUrl];
这在模拟器上工作正常,但在设备上不起作用
您确定不想让UIDocumentInteractionController为你做繁重的工作吗?
UIDocumentInteractionController *dc = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
dc.delegate = self;
[dc presentPreviewAnimated:YES];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)