Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从iCloud Drive iOS objective C下载图像_Ios_Xcode_Icloud_Icloud Drive - Fatal编程技术网

从iCloud Drive iOS objective C下载图像

从iCloud Drive iOS objective C下载图像,ios,xcode,icloud,icloud-drive,Ios,Xcode,Icloud,Icloud Drive,我已经通过了许多链接,但对我来说没有任何效果。我需要做的就是获取所有iCloud驱动器文件并下载图像。我使用下面的代码成功地获取了所有文件 - (void)presentDocumentPicker { NSArray *documentTypes = @[@"public.content", @"public.text", @"public.source-code ", @"public.image", @"public.audiovisual-content", @"com.ado

我已经通过了许多链接,但对我来说没有任何效果。我需要做的就是获取所有iCloud驱动器文件并下载图像。我使用下面的代码成功地获取了所有文件

 - (void)presentDocumentPicker {
    NSArray *documentTypes = @[@"public.content", @"public.text", @"public.source-code ", @"public.image", @"public.audiovisual-content", @"com.adobe.pdf", @"com.apple.keynote.key", @"com.microsoft.word.doc", @"com.microsoft.excel.xls", @"com.microsoft.powerpoint.ppt"];


    UIDocumentPickerViewController *documentPickerViewController = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeOpen];
    documentPickerViewController.delegate = self;
    [self presentViewController:documentPickerViewController animated:YES completion:nil];
}


#pragma mark - UIDocumentPickerDelegate

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
    self.documentURL = url;

    QLPreviewController *previewController = [[QLPreviewController alloc] init];
    previewController.delegate = self;
    previewController.dataSource = self;

    [self.navigationController pushViewController:previewController animated:YES];
}

现在我不知道如何进一步下载图像。

我可以使用此工具下载图像

    #pragma mark - UIDocumentPickerDelegate
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
    self.documentURL = url;


    NSNumber *isDownloadedValue = NULL;

    BOOL success = [url getResourceValue:&isDownloadedValue forKey: NSURLUbiquitousItemIsDownloadingKey error:NULL];

    if (success && ![isDownloadedValue boolValue]) {
        [[NSFileManager defaultManager]startDownloadingUbiquitousItemAtURL:url error:nil];

        // load image from Ubiquity Documents directory
        NSData *imageData = [NSData dataWithContentsOfURL:url];
           UIImage *     image = [UIImage imageWithData:imageData];
    }

    QLPreviewController *previewController = [[QLPreviewController alloc] init];
    previewController.delegate = self;
    previewController.dataSource = self;

    [self.navigationController pushViewController:previewController animated:YES];
}

下载图片时有什么问题?我需要从第一步开始的指导,因为我不知道如何开始。