Touch-To-Focus on cameraOverlayView in iOS 5?

2.3k views Asked by At

I used to have touch to focus on my cameraOverlayView (in UIImagePickerController), but once I updated to iOS 5 it doesn't work.

I used a custom view class which I applied to my view in cameraOverlayView. I made sure everything is connected and applied in Interface Builder. I don't want to show camera controls. (imagePicker.showsCameraControlls = NO).

This is my code in the OverlayView class:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UIView * previewView = [[[[[[[[[[
                                     self.picker.view // UILayoutContainerView
                                     subviews] objectAtIndex:0] // UINavigationTransitionView
                                   subviews] objectAtIndex:0] // UIViewControllerWrapperView
                                 subviews] objectAtIndex:0] // UIView

           subviews] objectAtIndex:0] // PLCameraView
                             subviews] objectAtIndex:0]; // PLPreviewView
    [previewView touchesBegan:touches withEvent:event];
    NSLog(@"Should Focus");
}

Do you guys have a different tap-to-focus method on an overlay?

Or do you know how to fix this?

THANK YOU SO MUCH IN ADVANCE!

1

There are 1 answers

1
user3145738 On

because ios5.0 Touch events are not getting forwarded to the view in the cameraOverlayView property of UIImagePickerController.

please changed you init code like this:

// self.cameraOverlayView = [[UIView alloc] init];
// [self.cameraOverlayView addSubview:previewView];

[self.view addSubview:mask];
[self.view bringSubviewToFront:previewView];