我想在我的应用中允许选择文档(pdf,doc,docx)。我想为此整合iCloud。我想做的就是从我的应用程序打开iCloud驱动器,用户可以选择该文件并返回原始应用程序。类似whatsapp的东西已经在iOS应用程序中进行了文档选择。
有关于此的任何想法吗?
答案 0 :(得分:17)
以下是代码:
-(IBAction)iCloudDriveFullFolder:(id)sender{
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"]
inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
}
#pragma mark - iCloud files
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
// NSString *alertMessage = [NSString stringWithFormat:@"Successfully imported %@", [url lastPathComponent]];
//do stuff
}
}