如何将文档保存到“文件"快速应用 [英] How to save document to "Files" App in swift
问题描述
我刚刚在我的应用程序中创建了一个 PDF 文档,我想以文件"应用程序可以访问已保存文档的方式将文档保存在设备上.
I just created a PDF document in my app and I want to save the document on the device in a way that the "Files" app can access the saved document.
当您在 Safari 中下载 PDF 文档时,可以选择将文档保存到文件"应用程序,这正是我正在尝试做的.
When you download a PDF document in Safari there is an option to save the document to the "Files" app, which is what I'm trying to do.
我用谷歌搜索了几个小时,但没有找到任何有用的方法.
I Googled for several hours but wasn't able to find any useful methods.
推荐答案
如果您有权访问您的 PDFdata
,那么您可以向用户展示一个 UIActivityViewController
然后将其保存到 Files
,或与任何其他可用选项共享:
If you have access to your PDFdata
then you could present the user with a UIActivityViewController
where they can then save it to Files
, or share it with any of the other available options:
let activityViewController = UIActivityViewController(activityItems: ["Name To Present to User", pdfData], applicationActivities: nil)
present(activityViewController, animated: true, completion: nil)
这篇关于如何将文档保存到“文件"快速应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!