Using the UIDocumentPickerViewController, is it possible to show a default service (Dropbox, Google Drive, etc) on first open like in Slack?

后端 未结 3 1863
青春惊慌失措
青春惊慌失措 2021-02-01 04:24

Normally, the behavior with UIDocumentPicker is that you present, then the user must use the \"Locations\" menu on the top right to switch between the services. Is it possible t

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 05:02

    Instead of using a UIDocumentPickerViewController, try using a UIDocumentMenuViewController. Here is the relevant documentation.

    UIDocumentMenuViewController *documentProviderMenu =
    [[UIDocumentMenuViewController alloc] initWithDocumentTypes:[self UTIs]
                                                         inMode:UIDocumentPickerModeImport];
    
    documentProviderMenu.delegate = self;
    [self presentViewController:documentProviderMenu animated:YES completion:nil];
    

    By default, this will display apps that include a Document Provider extension (such as Dropbox, Google Drive, iCloud, etc.). So if a user has Dropbox or Google Drive installed on their device, these options would show up automatically.

    You can also add custom options to the menu by calling the addOptionWithTitle:image:order:handler: method.

提交回复
热议问题