在iOS swift中使用UIDocumentPickerController的Doc文件问题?

问题描述 投票:3回答:3

我使用下面的代码来显示文档选择器。当我显示选择器时,我使用下面的代码

let documentPickerController = UIDocumentPickerViewController(documentTypes: [String(kUTTypeText), String(kUTTypePDF), String(kUTTypePNG), String(kUTTypeJPEG), String(kUTTypePlainText), String(kUTTypeImage)], in: .import)

上面的代码显示了我的iCloud中的所有文件,但它不允许我选择doc,docx文件。这些文件显示为禁用。

但是当我在qazxsw poi构造函数中添加qazxsw poi作为元素时,它允许我选择doc,docx文件和文件不会显示为禁用。

请告诉我为什么会这样?

ios swift xcode icloud uidocumentpickervc
3个回答
5
投票

为了能够选择doc和docx,您必须使用public.data。

com.microsoft.word.doc符合public.data

kUTTypePlainText只允许.txt类型的文件

只允许doc给出“"public.data"

UIDocumentPickerViewController

有关更多信息:com.microsoft.word.doc


2
投票

只需发布答案以帮助其他用户。

要通过文档选择器选择let documentPickerController = UIDocumentPickerViewController(documentTypes: [com.microsoft.word.doc], in: .import) 文件,您需要使用System-Declared Uniform Type Identifiers类型。

.docx

0
投票

对一堆类型的更多帮助:

org.openxmlformats.wordprocessingml.document
© www.soinside.com 2019 - 2024. All rights reserved.