20

I saw this question here: UIImagePicker allowsEditing stuck in center

It seems someone had this problem before, but there's no clear resolution.

Reproduction steps:

  1. Set allowsEditing = YES
  2. Take a picture
  3. Crop window comes up, but everytime I pan the image, it just snaps back to the center.

I'm on iOS 7.0.3.

Here's my code:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.delegate = self;
imagePicker.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
Community
  • 1
  • 1
chrysb
  • 1,351
  • 2
  • 13
  • 20
  • It works the same way on iOS 6. While it seems insane, I suspect that this is the way it is intended to work. The "edited" image is also very small (low pixel count) which has made it useless for my purposes. But I've been too lazy to do (or find) another editing solution. – Charlie Price Nov 15 '13 at 15:34
  • 1
    There's no way this can be working as intended. If you can't crop the image, why even allow the interaction? – chrysb Nov 15 '13 at 20:21
  • I can't disagree that it doesn't make sense. On the other hand, when I set allowsEditing to YES the returned "edited" image (iPhone 4s, iOS 7) is only 640x640 pixels (i.e. effectively a screen shot of the editing square on the image picker screen). That doesn't make sense either. I concluded that my idea of how it ought to work was simply not how Apple made it work. – Charlie Price Nov 15 '13 at 22:11
  • 1
    Fortunately, the images we use are 640x640 in the end. Strangely enough, the pan to crop works when you select an image from the photo library. To me, that indicates that the photo taken with the camera is not working as intended. – chrysb Nov 15 '13 at 23:07
  • Have you found a solution? For me, at iOS 7.1 a cropping window doesn't appear at all – itinance Jun 10 '14 at 20:02
  • I give up completely. It simply doesn't work. I present my own cropper immediately afterwards. –  Sep 27 '14 at 19:07
  • Please go through this link. It should help you out. http://stackoverflow.com/questions/9041732/set-dimensions-for-uiimagepickercontroller-move-and-scale-cropbox – fazeel ahamed Jan 13 '15 at 08:46

2 Answers2

1

You just need to write bellow single line of code.

UIImage *image = [info valueForKey:UIImagePickerControllerEditedImage];
Bhavesh Kumbhani
  • 555
  • 4
  • 11
  • Diff. kinds of images return in didFinishPickingMediaWithInfo.(UIImagePickerControllerCropRect, UIImagePickerControllerEditedImage, UIImagePickerControllerMediaTypem, UIImagePickerControllerOriginalImage, UIImagePickerControllerReferenceURL) – Bhavesh Kumbhani Mar 05 '16 at 07:38
-2
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
            picker.delegate = self;
            picker.allowsEditing = YES; // YES
            picker.sourceType = UIImagePickerControllerSourceTypeCamera;
            [self presentViewController:picker animated:YES completion:NULL];

try this i think you are missing the UIImagePickerControllerSourceTypeCamera on the sourceType. see if it works.

Eddwin Paz
  • 2,842
  • 4
  • 28
  • 48