我正在使用PDFKit
通过PDFView
功能在pdfView.document = document
中显示PDF文件。
这里是问题,我也使用UIDocumentPicker
API,每当我从didPickDocumentAt url
委托方法检索文档URL时,URL字符串的格式如下:
file:///private/var/mobile/Containers/Data/Application/09281711-BFB5-4B74-94A1-473F9B460EBD/tmp/com.ivancantarino.Cozynote-Inbox/Documento%20PDF.pdf
[如果以后我尝试使用PDFKit
预览该文档,则不会实例化该文档本身。
这里是示例代码:
let pdfView = PDFView()
pdfView.autoScales = true
view.addSubview(pdfView)
pdfView.frame = view.frame
// ... getting the document url, which comes in the following form:
// file:///private/var/mobile/Containers/Data/Application/09281711-BFB5-4B74-94A1- 473F9B460EBD/tmp/com.ivancantarino.Cozynote-Inbox/Documento%20PDF.pdf
// I'm saving the URL as a string, due to the databse entry
let url: String = ...
let document = PDFDocument(url: url)
pdfView.document = document
document
变量始终为nil,它无法将网址识别为合法路径。
我在这里做错什么了吗,或者有一种方法可以以任何不同的方式来做到这一点?
谢谢。
Delegate:-UIDocumentInteractionControllerDelegate