【发布时间】:2016-08-31 00:48:56
【问题描述】:
我需要制作一个自定义菜单,而不是带有按钮的 UIDocumentMenuViewController:iCloud、Dropbox 和 Google Drive。
是否可以在 UIDocumentPickerViewController 中立即打开 Dropbox 或 GoogleDrive(默认情况下会打开 iCloudDrive)?
【问题讨论】:
我需要制作一个自定义菜单,而不是带有按钮的 UIDocumentMenuViewController:iCloud、Dropbox 和 Google Drive。
是否可以在 UIDocumentPickerViewController 中立即打开 Dropbox 或 GoogleDrive(默认情况下会打开 iCloudDrive)?
【问题讨论】:
你应该使用 UIDocumentMenuViewController,比如
UIDocumentMenuViewController *menus = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];
menus.delegate = self;
[self presentViewController:menus animated:YES completion:nil];
在这个菜单中,用户可以选择 iCloud、google drive、Dropbox ...等 你显示句柄 UIDocumentPickerDelegate,UIDocumentMenuDelegate 来显示选择器并做一些事情
例如
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
// do something
}
}
- (void)documentMenu:(UIDocumentMenuViewController *)documentMenu didPickDocumentPicker:(UIDocumentPickerViewController *)documentPicker {
documentPicker.delegate = self;
[self presentViewController:documentPicker animated:YES completion:nil];
}
注意。 用户需要安装 google drive 或 dropbox 应用程序,然后才能看到驱动器菜单。
英语很差,希望你能听懂。
【讨论】: