Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cameraOverlayView prevents editing with allowsEditing

Editing a photo after it's been taken (moving and scaling it) works fine in my app with this line:

[imagePicker setAllowsEditing:YES];

But if I also use a cameraOverlayView, the editing mode doesn't work anymore. The screen comes up, but pan and pinch gestures don't make anything happen.

I'm using your average image picker controller:

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

And I add a camera overlay view, created from a custom view controller's view:

CameraOverlayViewController *overlayController = [[CameraOverlayViewController alloc] init];
UIView *overlayView = overlayController.view;
[imagePicker setCameraOverlayView:overlayView];

In IB, that view is set up to enable user interaction and multiple touch, which allows it to zoom and focus while taking the picture. But once the picture is taken and it enters editing mode, you cannot pan or pinch to move or scale the photo.

What am I missing?

like image 786
Steve Cotner Avatar asked Apr 16 '12 16:04

Steve Cotner


1 Answers

Does your overlay take up the entire space of the camera view? If so, touches are going to the overlay instead of the view below, even if you have a transparent background.

Add this method to your overlay view and it will ignore touches so that they are passed to the views below. (You are overriding a method of UIView that detects touches.)

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    return NO;
}

Note: as well as that fantastic tip, you may also want to use this piece of info, to remove your overlay view, at that stage: UIImagePicker cameraOverlayView appears on Retake screen

like image 90
Billy Shih Avatar answered Sep 25 '22 21:09

Billy Shih