0

我在我的应用程序中使用 Dropbox api。我已将 Dropbox 中的图像下载到应用程序文件夹中。现在我想上传照片。如果我使用 UIImagePicker,那么我无法从文件夹上传它,因为它需要保存的相册或相机。有没有办法将图像选择器中的图像保存在文档目录中?

4

1 回答 1

0

您必须实现委托方法imagePickerController:didFinishPickingMediaWithInfo。以下是你的做法——</p>

- (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您可能也感兴趣的键。

于 2011-05-24T07:56:56.297 回答