0

我需要允许 ppt、docx、xlsx 和 pdf 文件仅由我的应用程序中的文档选择器拾取。初始化文档选择器时需要设置哪些文档类型?

4

1 回答 1

1

我在下面提到的代码中添加了几种类型,请检查它是否解决了您的问题:

let types: [String] = [kUTTypePDF as String,kUTTypeSpreadsheet as String, kUTTypePresentation as String, "com.apple.iwork.pages.pages", "public.text"]
let documentPicker = UIDocumentPickerViewController(documentTypes: types, in: .import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: nil)

.

您可以尝试的其他可用类型:

“com.apple.iwork.pages.pages”、“com.apple.iwork.numbers.numbers”、“com.apple.iwork.keynote.key”、“public.image”、“com.apple.application”、 “public.item”、“public.data”、“public.content”、“public.audiovisual-content”、“public.movi​​e”、“public.audiovisual-content”、“public.video”、“public.audio” "、"public.text"、"public.data"、"public.zip-archive"、"com.pkware.zip-archive"、"public.composite-content"、"public.text"、""com. microsoft.word.doc"

如果您有任何问题,请发表评论。

乐意效劳!

于 2020-04-09T10:07:00.517 回答