问题描述
我正在尝试将以下功能放入我正在编写的 iOS 应用程序中:
I am attempting to put the following functionality into an iOS app I am writing:
- 在 XCode 中项目的资源文件夹中发送一组 PDF
- 将 PDF 复制到应用目录
- 在网络视图中打开 PDF.
据我所知,前两个步骤工作正常(复制操作后我使用 FileManager 检查 fileExistsAtPath).但是,webview 是空的,并且出错(请求的 URL 在服务器上不存在").我的文件打开代码如下:
As far as I can see, the first two steps work ok (I've used FileManager to check fileExistsAtPath after the copy operation). However, the webview is empty, and is erroring out ("the requested URL does not exist on server"). My code for the file open is as follows:
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];
这在模拟器上运行良好,但在设备上不起作用
This works fine on the simulator, but doesn't work on the device
推荐答案
正如上面 Anna Karenina 所说,设备区分大小写.确保文件名完全匹配"
As posted by Anna Karenina above, "The device is case-sensitive. Make sure the filename matches exactly"
这篇关于将本地 PDF 文件加载到 WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)