ios - 快速在 UIDocumentPicker 中设置文档扩展名
问题描述
我正在使用文档选择器来选择文档并上传到服务器。我只需要为允许的文档传递一些扩展名,但是我无法找出扩展名代表什么类型的文档。这是我想要允许的扩展列表。- docx - Microsoft Word - xlsx - Microsoft Excel - pptx - Microsoft Powerpoint - pdf - csv - pages - numbers - key - Keynote - rtf - txt 我知道一些扩展名,例如“kUTTypePDF,kUTTypeRTF”,但不是所有的都请帮忙。
解决方案
斯威夫特 5.0
let types = [kUTTypePDF, kUTTypeText, kUTTypeRTF, kUTTypeSpreadsheet] // You can add more types here as pr your expectation
let importMenu = UIDocumentPickerViewController(documentTypes: types as [String], in: .import)
试试这个
如果要选择所有文件,则必须使用以下代码:
let documentPicker = UIDocumentPickerViewController(documentTypes: ["com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers", "com.apple.iwork.keynote.key","public.image", "com.apple.application", "public.item", "public.content", "public.audiovisual-content", "public.movie", "public.audiovisual-content", "public.video", "public.audio", "public.text", "public.data", "public.zip-archive", "com.pkware.zip-archive", "public.composite-content"], in: .import)
推荐阅读
- php -
- python - ipython 尝试自动从 venv 启动
- javascript - 滑块栏两次显示为 HTML 表单?
- rust - 如何在 sqlx rust 中定义日期时间字段
- javascript - 如何在 JavaScript 中使用函数图绘制函数?
- python - 日期格式的 if 语句:datetime64[ns] 和 date
- python - 从 python 发送多个返回值以在发布数据时做出反应
- macos - 每次都使用相同的 shell 脚本文件
- c# - 使用 C# 和 Flurl 到 Joplin REST API 的多部分 POST
- c - 为什么我可以从 int**(作为二维数组)转换为 int*?