【发布时间】:2011-05-24 15:56:56
【问题描述】:
我在我的应用程序中使用了 Dropbox api。我已将 Dropbox 中的图像下载到应用程序文件夹中。现在我想上传照片。如果我使用 UIImagePicker,那么我无法从文件夹上传它,因为它需要保存的相册或相机。有什么方法可以将图像选择器中的图像保存在文档目录中吗?
【问题讨论】:
标签: iphone uiimagepickercontroller dropbox-api
我在我的应用程序中使用了 Dropbox api。我已将 Dropbox 中的图像下载到应用程序文件夹中。现在我想上传照片。如果我使用 UIImagePicker,那么我无法从文件夹上传它,因为它需要保存的相册或相机。有什么方法可以将图像选择器中的图像保存在文档目录中吗?
【问题讨论】:
标签: iphone uiimagepickercontroller dropbox-api
你必须实现委托方法imagePickerController:didFinishPickingMediaWithInfo。以下是你的做法——
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
...
// Get filePath here
...
[imageData writeToFile:filePath atomically:YES];
}
还有另一个密钥UIImagePickerControllerEditedImage,您可能也会感兴趣。
【讨论】:
PhotoLibrary 模式在模拟器中进行测试,因为相机不可用。但在产品中应该是你提到的。