在我的应用程序中,我使用UIDocumentPickerViewController
来允许用户选择文件(导入),但从iOS 13开始,该功能停止工作,基本上文档选择器是打开的,但用户无法选择文件(点击文件无反应)。
我创建了一个简单的示例以隔离代码:
class ViewController: UIViewController, UIDocumentPickerDelegate {
@IBAction func openDocumentPicker(_ sender: Any) {
let types = [String(kUTTypePDF)]
let documentPickerViewController = UIDocumentPickerViewController(documentTypes: types, in: .import)
documentPickerViewController.delegate = self
present(documentPickerViewController, animated: true, completion: nil)
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("Cancelled")
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
print("didPickDocuments at \(urls)")
}
}
示例项目: https://github.com/Abreu0101/document-picker-iOS13-issue