Objective-c – UIImagePickerController allowsEditing=YES Issue

iphoneobjective cuiimagepickercontrolleruser interface

I am still having this issue with the uiimagepickercontroller. It is supposed to be straight forward, but I still can't figure it out. Or maybe Im going in the wrong direction.

I call the imagepicker so that user can load a photo from camera roll/photo album/take a photo from camera. This part is fine.

It becomes weird when i set allowsEditing to YES. the didiFinishPickingMediaWithInfo delegate returns an NSDictionary *info with BOTH the editedImage and originalImage in it, even when user did NOT crop the image shown in the picker. So the problem is how can i detect whether the user cropped the image or not?

What I need for my app is the user is allowed to crop the image if he wishes to, but he also is given the choice NOT to crop, thus returning the original photo. Currently I am using a segmentedcontrol for user to pre-select before loading a photo, which I think is pretty inconvenience. And maybe some user does not understand it.

So how can I implement what I need without troubling the user so much?

Best Answer

I'm pretty sure you must edit the image if the edit controls are shown. I don't know of any way to get rid of the square.

However, if I'm wrong about that you could compare their sizes:

editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];

if ((editedImage.size.width != originalImage.size.width) || (editedImage.size.height != originalImage.size.height)) {
    // The image has been edited
}
Related Topic