我的文档选择器打开正常,我可以看到我的所有文件(谷歌驱动器),但当我选择一个,没有任何反应。视图解散了,就是这样。我错过了什么吗?这在更新的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)")
}