【问题标题】:how to initalise UIDocumentPickerViewController noting "forOpeningContentTypes" (from doco) seems to be deprecated in IOS?如何初始化 UIDocumentPickerViewController 注意到“forOpeningContentTypes”(来自 doco)在 IOS 中似乎已被弃用?
【发布时间】:2021-10-18 22:42:18
【问题描述】:

在使用 IOS 14.5 部署目标的 Xcode 12.5.1 中遵循 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

错误快照:

如何在此处使用文档选择器的文档:

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

【问题讨论】:

  • 为我工作 - Xcode 12.5 (12E262)

标签: ios swift xcode uidocument uidocumentpickerviewcontroller


【解决方案1】:

你忘了

import UniformTypeIdentifiers

【讨论】:

  • 我没有这样做,但它仍然有效......我导入了 SwiftUI,也许自动导入 UniformTypeIdentifiers
  • 这行得通 - 实际上这是怎么回事 - 可用于类的 Swift 函数是否会根据您作为导入的内容而动态变化?
  • @Greg 新的初始化程序需要 UTType,它不是 Foundation 和/或 UIKit 的一部分。这就是你需要导入 UniformTypeIdentifiers 框架的原因。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-03
  • 2021-11-02
  • 1970-01-01
  • 2019-03-09
  • 2020-10-10
  • 1970-01-01
相关资源
最近更新 更多