小编Jul*_*ang的帖子

如何将 UTType 与 UIdocumentPicker 一起使用(页面?docx?)

我正在尝试打开一个仅允许某些文件类型的选择器。我正在使用此文档来查找我需要的 UTTYpe: https://developer.apple.com/documentation/uniformtypeidentifiers/uttype/system_declared_uniform_type_identifiers

但我找不到 .pages、.doc、.docx 的 UTTYpe...

我应该怎么办?

这是我目前的代码

    func presentPickerDocument() {
    //Create a picker specifying file type and mode
    var supportedTypes: [UTType]
    supportedTypes = [UTType.pdf, UTType.url]

    let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
    documentPicker.delegate = self
    documentPicker.allowsMultipleSelection = false
    present(documentPicker, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

types file swift uidocumentpickerviewcontroller uttype

2
推荐指数
1
解决办法
3310
查看次数