在我的应用程序中,我曾经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