2

When using UIDocumentPickerViewController for importing data into my app, I would like to remember the last service/location that was chosen by the user, and start the navigation with that service.

E.g. if a user imports something from Dropbox, and then later on wants to import something again, I would like the document picker to start with Dropbox as the initial location.

Unfortunately, the default behaviour is that the picker always starts with iCloud Drive, so each time a user wants to import something from Dropbox, they have to tap on Locations, and pick Dropbox from there - two unnecessary taps.

I've tried to keep a strong reference to a previously shown picker, but presenting that picker again doesn't seem to work - it just shows a blank view.

    if(self.documentPicker) {
        [self presentViewController:self.documentPicker animated:YES completion:nil];
        return;
    }

    UIDocumentPickerViewController *vc = 
    [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.audio"] inMode:UIDocumentPickerModeImport];
    vc.delegate = self;
    self.documentPicker = vc;
    [self presentViewController:vc animated:YES completion:nil];

There's also UIDocumentMenuViewController, which lets you choose a location/service up front and lets you then show the document picker which was chosen by it, but again, I have found no way to store a reference to a location with which to show a document picker in future import actions.

cheers!

spinalwrap
  • 683
  • 1
  • 4
  • 17
  • Possible duplicate of: https://stackoverflow.com/questions/31070588/using-the-uidocumentpickerviewcontroller-is-it-possible-to-show-a-default-servi – fishinear Aug 13 '17 at 18:03

0 Answers0