ios - 保存文件时选择目的地
解决方案
是的,对于 iOS 13 及更高版本,您可以要求用户通过UIDocumentPickerViewController
. 您将获得用户选择的目录的安全范围 url。
此处的详细信息:https ://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories
我已经从下面那个页面粘贴了示例代码,但是您需要仔细阅读文档,因为安全范围的 URL 需要小心处理:)
如果您需要 iOS 12 或更早版本,用户只能选择文件,所以我不清楚执行此操作的干净方式(但我们在 iOS 14 上,iOS 15 即将推出,所以希望您不必支持回到iOS 13)。
这是上面链接中的示例代码,显示了这是如何完成的:
// Create a document picker for directories.
let documentPicker =
UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
documentPicker.delegate = self
// Set the initial directory.
documentPicker.directoryURL = startingDirectory
// Present the document picker.
present(documentPicker, animated: true, completion: nil)
推荐阅读
- jquery - 如何在 JQuery Datepicker 中阻止上一年?
- python - 如果找不到 Django REST Framework 的详细信息,如何修改 ModelViewSet 类中的错误响应?
- javascript - 如何验证 sessionid 和响应的动态 ID 始终是唯一的
- javascript - 在纯 JavaScript 中一次打开一个菜单的切换菜单
- c# - 使用 URL WPF 打开浏览器
- javascript - 是否可以在没有 react-router-dom 的情况下处理路由?
- excel - 如何使用 VBA 编码执行 SumIf 或 SumProduct 函数以跨多个工作表求和
- java - 同一数据访问对象的不同验证注释规则
- python - 是否可以在 python 的 PYQT5 中集成支付通道
- c - 我将如何在 C 中反转二维数组?