ios - 如何初始化 UIDocumentPickerViewController 注意到 "forOpeningContentTypes"(来自 doco)似乎在 IOS 中已被弃用?

标签 ios swift xcode uidocument uidocumentpickerviewcontroller

在 Xcode 12.5.1 中使用 IOS 14.5 部署目标遵循 UIDocumentPickerViewController 的现场 IOS 文档时,出现错误:

Incorrect argument label in call (have 'forOpeningContentTypes:', expected 'forExporting:')

关于现在应该如何使用 IOS UIDocumentPickerViewController 有什么建议吗?

我的代码除了:

// Create a document picker for directories.
let documentPicker =
    UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
documentPicker.delegate = self

错误快照:

enter image description here

有关如何使用文档选择器的文档:

https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories给出:

最佳答案

你忘了

import UniformTypeIdentifiers

关于ios - 如何初始化 UIDocumentPickerViewController 注意到 "forOpeningContentTypes"(来自 doco)似乎在 IOS 中已被弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68810300/

相关文章:

ios - VC之间传输数据

ios - 从 Openweathermap IOS 4 Xcode 10 获取 json 数据后 UI 不会更新

ios - 如何检查 Web 服务器是否具有 SSL

ios - Xcode 7.3 调试器不显示自定义类变量

objective-c - xcode xib 文件中文件所有者的需求是什么?我可以在没有文件所有者的情况下做同样的事情吗?

ios - 为 xcode 项目设置默认字体样式、颜色和大小

ios - URL(fileURLWithPath : Bundle. main.path(forResource : "ports", ofType : "geojson")!) 为零?

iphone - objective-c - tableview 内的按钮防止表格滚动

ios - 从我的首选项 Pane 中删除 "Siri & Search"?

ios - Alamofire 上传进度