在我的应用程序中,我使用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
参考资料:

发布于 2019-11-23 05:27:18
当我遇到这个问题时,我意识到当我从“浏览”标签中选择文件时,它是起作用的,因为我实现了"didPickDocumentAt“方法,但是当我点击”最近“标签中的文件时,它就不起作用了。
为了让它在“最近”选项卡上工作,我想实现方法"didPickDocumentsAt",,它做同样的事情,但它处理一个URL数组。
发布于 2019-12-22 03:52:25
发布于 2019-11-19 16:28:12
我在iOS 13.2.2上列出了这个问题。已更新到iOS 13.2.3,无需更改任何代码即可修复此问题。
https://stackoverflow.com/questions/57862786
复制相似问题