简体   繁体   English

在iOS应用中打开iCloud Drive

[英]Open iCloud Drive in iOS app

I want to allow document(pdf, doc, docx) selection in my app. 我想在我的应用程序中选择文档(pdf,doc,docx)。 And I want to integrate iCloud for this. 我想为此整合iCloud。 All I want to do is to open the iCloud drive from my app and there user can select the file and returns back to the origin app. 我想做的就是从我的应用程序打开iCloud驱动器,用户可以选择该文件并返回原始应用程序。 Something like whatsapp has done for document selection in iOS app. 类似whatsapp的东西已经在iOS应用程序中进行了文档选择。

Any idea regarding this? 对此有何想法?

Read this below link you will get idea: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentPickerProgrammingGuide/AccessingDocuments/AccessingDocuments.html 阅读以下链接,您将获得想法: https//developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentPickerProgrammingGuide/AccessingDocuments/AccessingDocuments.html

Below is the code : 以下是代码:

-(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

    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM