首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIDocumentPickerViewController iOS13不工作

UIDocumentPickerViewController iOS13不工作
EN

Stack Overflow用户
提问于 2019-09-10 09:02:09
回答 3查看 5.1K关注 0票数 21

在我的应用程序中,我使用UIDocumentPickerViewController允许用户选择文件(导入),但从iOS 13开始,该功能停止工作,基本上文档选取器是打开的,但用户不能选择文件(录制文件不起任何作用)。

我制作了一个简单的示例来隔离代码:

代码语言:javascript
复制
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

参考资料:

EN

回答 3

Stack Overflow用户

发布于 2019-11-23 05:27:18

当我遇到这个问题时,我意识到当我从“浏览”标签中选择文件时,它是起作用的,因为我实现了"didPickDocumentAt“方法,但是当我点击”最近“标签中的文件时,它就不起作用了。

为了让它在“最近”选项卡上工作,我想实现方法"didPickDocumentsAt",,它做同样的事情,但它处理一个URL数组。

票数 2
EN

Stack Overflow用户

发布于 2019-12-22 03:52:25

Stack Overflow用户

发布于 2019-11-19 16:28:12

我在iOS 13.2.2上列出了这个问题。已更新到iOS 13.2.3,无需更改任何代码即可修复此问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57862786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档