6 Replies
      Latest reply on Oct 23, 2019 11:57 AM by julio83
      cfc Level 1 Level 1 (20 points)

        I am having problems with UIDocumentPickerViewController.  The didPickDocumentsAtURLs delegate is not getting called when selecting a file in the picker controller.  The delegate is working because documentPickerWasCancelled is corrected called when Cancel is pressed.  I am using public.xml to specify GPX documents (I may narrow it down later) and they are correctly enabled, but for some reason the delegate is not called when they are tapped.

         

        In the log I see a "Failed to associate thumbnails for picked URL" warning when a file is tapped but apparently this is not an issue (according to https://stackoverflow.com/questions/51793060/icloud-drive-issue-documentmanager-failed-to-associate-thumbnails-for-picked).

         

        I am using iOS 12.4 and have tried with both single and multiple selection.  I have added iCloud capabilities and linked the MobileCoreServices framework, but neither made any difference.

         

        Has anyone got any idea what I am doing wrong?

        • Re: UIDocumentPickerViewController problem
          Claude31 Level 8 Level 8 (6,865 points)

          Sorry for the basic question. Have you set the delegate for the picker ?

            • Re: UIDocumentPickerViewController problem
              cfc Level 1 Level 1 (20 points)

              Yes I think so.  documentPickerWasCancelled is called when Cancel is tapped, so I think that the delegate is working, but just not for didPickDocumentsAtURLs for some reason.  I also tried the old didPickDocumentAtURL method, but that didn't work either.

                • Re: UIDocumentPickerViewController problem
                  cfc Level 1 Level 1 (20 points)

                  I don't know if it is related but the reason I am adding the picker is because importing of GPX files into my app has stopped working in the iOS 13 beta (118932).  It is getting close to the GM, so I am getting worried and decided to add the picker as an alternative in case it isn't fixed.  However the picker doesn't work either, even in iOS 12.4.

                   

                  Could it be related to my Document Types or Imported/Exported UTIs?  They worked fine with previous versions of iOS but not with the iOS 13 beta.  I have tried pretty much every combination and hint that I can find in the developer resources and on the web, but none of them have made any difference.

              • Re: UIDocumentPickerViewController problem
                cfc Level 1 Level 1 (20 points)

                I got around this problem by presenting the view controller modally with presentViewController instead of pushing it on the stack using pushViewController.

                • Re: UIDocumentPickerViewController problem
                  ccamargo Level 1 Level 1 (0 points)

                  I have the same problem but as I'm using SwiftUI and a NavigationLink to present the UIdocumentPickerViewController I can't present it as a modal. If anyone found a better solution to this, please, tell me.

                    • Re: UIDocumentPickerViewController problem
                      julio83 Level 1 Level 1 (0 points)

                      To present a modal view you use sheet. Something similar that the extract of code here

                       

                      @State showSheet = false

                       

                      NavigationView {

                                      content

                                          .navigationBarTitle(self.title)

                                          .navigationBarItems(leading:

                                              NavigationLink(destination: MenuView()) {

                                                  Image(systemName: "square.grid.3x2").font(.system(size: 24))

                                              },

                                                              trailing:

                                              Button(action: {

                                                  withAnimation {

                                                      self.showSheet = true

                                                  }

                                              }) {

                                                  Image(systemName: "plus.circle").font(.system(size: 24))

                                              }

                                      )

                                          .listStyle(GroupedListStyle())

                                  }

                                  .sheet(isPresented: $showSheet) {

                                      WebViewRepresentation()

                                  }