Ios 在swift中使用UIDocumentPickerViewController(documentTypes:)
在我的代码中使用UIDocumentPickerViewConroller在应用程序中选择音频文件时,出现了此错误,我在UIDocumentPickerViewController中找不到Ios 在swift中使用UIDocumentPickerViewController(documentTypes:),ios,swift,Ios,Swift,在我的代码中使用UIDocumentPickerViewConroller在应用程序中选择音频文件时,出现了此错误,我在UIDocumentPickerViewController中找不到(documentTypes:) iOS 14.0中不推荐使用UIDocumentPickerMode中的UIDocumentPickerServiceController(documentTypes:[String]) 该方法将替换为此UIDocumentPickerViewController(用于打开c
(documentTypes:)
iOS 14.0中不推荐使用UIDocumentPickerMode中的UIDocumentPickerServiceController(documentTypes:[String])
该方法将替换为此UIDocumentPickerViewController(用于打开contentTypes contentTypes:[UTType],asCopy:Bool)方法
首先,需要导入UniformTypeIdentifiers
import UniformTypeIdentifiers
因此,您可以按如下方式使用它
let supportedTypes: [UTType] = [UTType.audio]
let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
pickerViewController.delegate = self
pickerViewController.allowsMultipleSelection = false
pickerViewController.shouldShowFileExtensions = true
self.present(pickerViewController, animated: true, completion: nil)
iOS 14.0中不推荐使用UIDocumentPickerMode中的UIDocumentPickerServiceController(documentTypes:[String])
该方法将替换为此UIDocumentPickerViewController(用于打开contentTypes contentTypes:[UTType],asCopy:Bool)方法
首先,需要导入UniformTypeIdentifiers
import UniformTypeIdentifiers
因此,您可以按如下方式使用它
let supportedTypes: [UTType] = [UTType.audio]
let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
pickerViewController.delegate = self
pickerViewController.allowsMultipleSelection = false
pickerViewController.shouldShowFileExtensions = true
self.present(pickerViewController, animated: true, completion: nil)
导入导入MobileCoreServices框架了吗?导入导入了导入MobileCoreServices框架了吗?我尝试了,但无法导入UniformTypeIdentifiers。我应该更新Xcode吗?哪是你的Xcode版本?我现在正在下载12.5,我已经下载了Xcode版本12.2,它正在运行。我会再试一次。我试过了,但我无法导入UniformTypeIdentifiers。我应该更新Xcode吗?哪一个是你的Xcode版本?我现在正在下载12.5我已经下载了Xcode版本12.2,它可以正常工作了,我会再试一次