4

My document picker opens properly and I can see all my files (google drive), but when I select one, nothing happens. The view dismisses back and thats it. Am I missing something? This was working before updated Xcode and 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)
}

Nothing is 'failing' either, it just isn't calling that documentPicker method.

I have a similar one for selecting media and that one works fine...

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)")
}
John
  • 1,808
  • 7
  • 28
  • 57

0 Answers0