【问题标题】:Dropbox photo uploadingDropbox照片上传
【发布时间】:2011-05-24 15:56:56
【问题描述】:

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

【问题讨论】:

    标签: iphone uiimagepickercontroller dropbox-api


    【解决方案1】:

    你必须实现委托方法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,您可能也会感兴趣。

    【讨论】:

    • 我应该使用 uiimagepickercontrollersourcetypecamera 吗?以及如何在模拟器上进行测试
    • 我必须将照片保存在文件夹中。在这种情况下,我必须从某个地方拍摄图像。我必须为此使用相机,否则我必须将已保存的图像保存到文件夹..?
    • 不,我的意思是使用PhotoLibrary 模式在模拟器中进行测试,因为相机不可用。但在产品中应该是你提到的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-14
    • 2013-08-23
    • 2011-06-04
    • 2017-02-18
    • 2012-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多