Question

I used to use the old-school method of adding an overlay to the camera screen, and that worked fine. However, since 3.1 came out, Apple is insisting that I use the API to add an overlay. I quickly got the overlay to work, but it seems that if I use the custom overlay, then the move & resize screen is not responsive, I can only use or retake, can't actually resize & move. The code I am using is below. I have tried several variations, but the only thing that actually enables the move & resize is to remove the line that adds the custom overlay view.

Any ideas?

UIImage *image = [UIImage imageNamed:@"camera-template-long.png"];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] ;
imgView.image = image;

UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
overlayView.opaque = NO;
[overlayView addSubview:imgView];

UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;        
picker.showsCameraControls = YES;
picker.cameraOverlayView = overlayView;
picker.delegate = self;
picker.allowsEditing = YES;

[self presentModalViewController:picker animated:YES];
Was it helpful?

Solution 2

The entire issue goes away once you use [overlayView setUserInteractionEnabled:NO]; to stop the overlay view from handling the input.

OTHER TIPS

Set both allowsEditing/showsCameraControls properties to NO, prepare your original view to cameraOverlayView, and use takePicture method.

Then, imagePickerController:didFinishPickingMediaWithInfo: will be called directly.


Please try the following code:

- (void)foo {
  UIImagePickerController *controller = [[[UIImagePickerController alloc] init] autorelease]; 
  controller.sourceType = UIImagePickerControllerSourceTypeCamera; 
  controller.cameraOverlayView = self.cameraOverlay; 
  [self performSelector:@selector(moveOverlayViewToSublayer:) withObject:controller afterDelay:0.1f]; 
  controller.delegate = self; 
  [self presentModalViewController:controller animated:YES]; 
}
- (void) moveOverlayViewToSublayer:(UIImagePickerController*)controller { 
  CALayer *aLayer = self.cameraOverlay.layer.superlayer; 
  controller.cameraOverlayView = nil; 
  [aLayer addSublayer:self.cameraOverlay.layer]; 
}

I hope it will work well.

http://www.techques.com/question/1-10178214/cameraOverlayView-prevents-editing-with-allowsEditing

This works perfectly for me. I tried to disable userInteractionEnabled but in vain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top