swift - 如何让用户选择本地文档?
问题描述
我应该以允许用户打开本地保存的 pdf 文件的方式测试 PSPDFKit。为此,我需要文件 url(例如路径,我猜)。如何让用户选择本地文档?有人可以帮帮我吗?我正在使用故事板和swift。
解决方案
您可以使用类似的方法在 PSPDFKit 中呈现 PDF 文档PDFViewController
:
// Create the `Document`.
let fileURL = Bundle.main.url(forResource: "Document", withExtension: "pdf")!
let document = Document(url: fileURL)
// Create the PDF view controller.
let pdfController = PDFViewController(document: document)
// Present the PDF view controller within a `UINavigationController` to enable the toolbar.
present(UINavigationController(rootViewController: pdfController), animated: true)
有关更多详细信息,请在此处查看以下指南。
此外,要呈现最终用户选择的文档,请考虑使用文档选择器或文件浏览器。有关可运行的示例项目,请参阅Catalog和SwiftUI 文档浏览器中的DocumentPickerSidebarExample.swift 。
将来,请通过 pspdfkit.com/support/request/ 联系我们的支持门户 - 我们很高兴在那里为我们的商业 SDK 提供支持。
推荐阅读
- c# - 为什么当应用程序在我的计算机上运行时 System.DateTime.Now 工作,但当我通过工作组启动应用程序时不工作?
- spring-boot - spring-boot-starter-quartz 指定不同的数据库连接器?
- html - css中的三倍大于选择器是什么?
- java - 如何在函数中用对象填充数组,而我在主函数中声明了这个数组?
- django - 我可以使用 Django 动态覆盖静态文件吗?
- raster - 在写入栅格时保留图层名称
- excel - excel中的时间戳基于两列中先前的单元格条目
- html - 当我需要向下滚动站点时出现水平滚动
- objective-c - 如何在objective-c中导入Metal?
- python - 在 Python 3.6.8 中按 32 右移返回不正确的值