Reputation: 6042
I'm attempting to use a cameraOverlay to simulate iOS's 'square mode' for an image picker as this feature is not implemented. (In the style of this question.) This is in an iPad app.
My issue is that for the first screen, I can use all the controls perfectly fine. However for the second screen of the imagepicker, it is not possible to interact with the buttons.
My overlay is the size of picker.bounds
- and I believe this is blocking the interaction with my buttons, as if I rotate my screen landscape, I can interact with the right hand button only...
So, the direct questions: 1) Is it possible to force the tool button to respond to touched through the cameraOverlay layer? 2) Or instead, is it possible to bring the toolbar ABOVE the cameraOverlay. (Why you would ever want it underneath I don't know, especially seeing as you can hide it. I believe this to be a bug in iOS)
Images:
Screen one, buttons work fine
Screen two, buttons don't respond. (Through overlay)
My code:
if (type == UIImagePickerControllerSourceTypeCamera) {
//Create camera overlay
CGRect f = picker.view.bounds;
CGFloat barHeight = (f.size.height - f.size.width) / 2;
UIGraphicsBeginImageContext(f.size);
[[UIColor colorWithWhite:0 alpha:1] set];
UIRectFillUsingBlendMode(CGRectMake(0, 0, f.size.width, barHeight), kCGBlendModeNormal);
UIImage *overlayImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *overlayIV = [[UIImageView alloc] initWithFrame:f];
overlayIV.image = overlayImage;
[picker.toolbar setUserInteractionEnabled:YES];
[picker.cameraOverlayView addSubview:overlayIV];
[picker.cameraOverlayView bringSubviewToFront:picker.toolbar];
}
[self presentViewController:picker animated:YES completion:nil];
Upvotes: 0
Views: 402
Reputation: 5953
Can't you just say:
picker.cameraOverlayView.userInteractionEnabled= NO;
overlayIV.userInteractionEnabled= NO;
IIRC, UIImageView defaults to userInteractionEnabled NO, so that last part may be unnecessary.
Upvotes: 1