【发布时间】:2018-01-10 09:57:10
【问题描述】:
在我用于在 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 中实现。
【问题讨论】:
-
“但没有得到肯定的结果”请提供您的代码、测试用例、错误消息等。没有具体细节,没有人可以调试您的问题
标签: ios objective-c xcode nsfilemanager icloud-drive