cameraOverlayView prevents editing with allowsEditing

≡放荡痞女 提交于 2019-12-04 20:45:31

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/10178214/cameraoverlayview-prevents-editing-with-allowsediting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!