imagePickerController返回0字节的图像

时间:2016-02-19 02:48:06

标签: ios xcode ipad uiimage uiimagepickercontroller

我有一个iPad应用程序,我试图让用户用相机拍照,然后将其保存到我的服务器。但出于某种原因,UIImage从

返回
- (void)imagePickerController:(UIImagePickerController *)thePicker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo

返回0字节的图像......

this is what happens when someone clicks use photo

奇怪的是我可以在UIImageView中很好地显示这个图像,但是当我尝试将它保存到我的服务器时,它会发送0个字节,因此不会保存任何内容。

我很难过,有什么想法吗?

非常感谢您的任何建议,

3 个答案:

答案 0 :(得分:0)

试试这个

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

        UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
        UIImage *newImage = [self scaleAndRoateImage:chosenImage];

        [picker dismissViewControllerAnimated:YES completion:nil];
    }];
}

希望这能帮到你

答案 1 :(得分:0)

在访问信息词典之前显然解雇了imageController解决了这个问题。

所以试试

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

        [picker dismissViewControllerAnimated:YES completion:nil];
        UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
        UIImage *newImage = [self scaleAndRoateImage:chosenImage];

    }];
}

更多信息:

http://iphonedevsdk.com/forum/iphone-sdk-development/52639-uiimagepickercontroller-issue-did-i-miss-something.html#post266218

答案 2 :(得分:0)

签入此委托方法:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
   UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
}