UIDocumentPickerViewController 不响应在 iOS 13 和 iOS 14 上选择的文档

问题描述

我正在尝试在我的应用程序中实现 documentPicker,但在选择 PDF 文件时它什么也不做 我看着那些 answersthis 和 我试图在 iOS13.0 和 ios14.4 上运行它,也是在 iOS 14.4 上运行的物理设备,但它不起作用

我正在使用 macOS Big Sur 11.2.3 / Xcode 12.4

   @objc func uploadDocumentTapped() {

  let documentPicker = UIDocumentPickerViewController(documentTypes: [String(kUTTypePDF)],in: .import)
   documentPicker.delegate = self
   documentPicker.modalPresentationStyle = .formSheet
     self.dismiss(animated: true) { //dismiss presentation Controller
            let top = UIApplication.shared.keyWindow?.rootViewController
            top?.present(documentPicker,animated: true,completion: nil)
        }
}


 extension UploadDocumentMenuViewController: UIDocumentPickerDelegate {

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
        print("cancelled")
    }

    func documentPicker(_ controller: UIDocumentPickerViewController,didPickDocumentsAt urls: [URL]) {

print("URL Documents \(urls)")

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)