UIDocumentPickerViewController永远不会调用didPickDocument方法

时间:2016-10-19 16:50:31

标签: swift uidocumentpickervc

我的文档选择器打开正常,我可以看到我的所有文件(谷歌驱动器),但当我选择一个,没有任何反应。视图解散了,就是这样。我错过了什么吗?这在更新的Xcode和Swift之前有效。

func selectDocument(_ sender: UIButton!){
    let documentPickerVC = UIDocumentPickerViewController(documentTypes: ["org.openxmlformats.wordprocessingml.document", "com.microsoft.word.doc"], in: UIDocumentPickerMode.import)
    documentPickerVC.delegate = self
    self.present(documentPickerVC, animated: true, completion: nil)
}

func documentPicker(_ documentPicker: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
    print("file picked: \(url)")
    documentPicker.dismiss(animated: true, completion: nil)
}

没有什么是失败的'或者,它只是不调用documentPicker方法。

我有一个类似的选择媒体,一个工作正常......

func selectMedia(_ sender: UIButton!){
    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary){
        picker.delegate = self
        picker.allowsEditing = false
        picker.mediaTypes = [kUTTypeMovie as String]
        self.present(picker, animated: true, completion: nil)
    }
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info:[String: Any]) {
    let url = info[UIImagePickerControllerMediaURL] as! URL
    print("media picked: \(url)")
}

0 个答案:

没有答案