下面是我用于在 iCloud 上上传图像的代码,我成功地将图像上传到 iCloud,但用户需要选择目录,因为我正在使用他们的 pickerView。
现在我需要将我的图像放入 iCloud 的特定文件夹中。怎么做?
#pragma mark - Image Picker view Delegates
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:( NSDictionary *)editingInfo
{
NSLog(@" User has selected the image ");
[picker dismissViewControllerAnimated:YES completion:nil];
if (image!=nil)
{
NSLog(@"Image is Obtain");
/*
* Allow Image upload to the iCloud
*
*/
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"Sample.png"]];
NSLog(@"%@",filePath);
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
NSURL* fileUrl = [NSURL fileURLWithPath:filePath];
NSLog(@"%@",fileUrl);
//Create a object of document picker view and set the mode to Export
UIDocumentPickerViewController *docPicker = [[UIDocumentPickerViewController alloc] initWithURL:fileUrl inMode:UIDocumentPickerModeExportToService];
//Set the delegate
docPicker.delegate = (id)(self);
//present the document picker
[self presentViewController:docPicker animated:YES completion:nil];
}
}
这里我解释一下我的情况:
我需要将照片/相机中的图像上传到特定文件夹让我们说以iCloud
编程方式实现的“图像”Objective C
现在进一步,我必须访问 iCloud 中可用的特定文件夹Objective C
。