使用UIDocumentPickerViewController不会出现icloud驱动器

时间:2019-02-25 08:35:26

标签: swift xcode icloud uidocumentpickerviewcontroller

你好,在我的应用中,我想从iCloud导入.sqlite来还原数据,但是它没有显示iCloud驱动器上的所有内容都已被管理,iCloud权利已经启用,并且已从开发人员帐户启用了该功能

ICloud entitlements

在我的应用中,我已经集成了此代码

    @IBAction func btnImport(_ sender: Any) {
        //let importMenu = UIDocumentPickerViewController(documentTypes: [String(kUTTypePDF)], in: .import)
        let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePNG),String(kUTTypeImage)], in: .import)
        importMenu.delegate = self
        importMenu.modalPresentationStyle = .fullScreen
        self.present(importMenu, animated: true, completion: nil)
    }


extension MoreViewController : UIDocumentMenuDelegate, UIDocumentPickerDelegate {

    func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
        documentPicker.delegate = self
        self.present(documentPicker, animated: true, completion: nil)
    }

    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
        print("url = \(url)")
    }

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
        dismiss(animated: true, completion: nil)
    }
}

但这只显示了我

输出

enter image description here

0 个答案:

没有答案