After Taking Picture cannot select Use Photo or Retake

PorthosJon picture PorthosJon · Sep 26, 2013 · Viewed 7.3k times · Source

So I'm trying to update an app for iOS 7 and I'm running into issues with my custom overlay. The overlay is an image that I'm framing the photo with (both live and using a full resolution version to frame the final result in the camera roll). The problem is that now, under iOS 7, the overlay, while transparent at the bottom, provides access to the regular "take picture" button, but for some reason will not let me tap on the "Use Photo" or "Retake" buttons that come up after the picture is snapped. Here's the code snippet calling the view controller:

- (IBAction)takePhoto:(UIButton *)sender {

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

// Overlay Creation
UIView* overlayView = [[UIView alloc] initWithFrame:picker.view.frame];
    overlayView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"PBOverlayView.png"]];
    [overlayView.layer setOpaque:NO];
    overlayView.opaque = NO;

picker.cameraOverlayView = overlayView;

[self presentViewController:picker animated:YES completion:NULL];

}

Answer

joneswah picture joneswah · Jun 30, 2014

Another approach could be to observe the notifications when the ImagePicker changes state and remove (or disable) your overlay when you move into the "Use Photo" screen.

- (void) addPhotoObservers {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeCameraOverlay) name:@"_UIImagePickerControllerUserDidCaptureItem" object:nil ];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCameraOverlay) name:@"_UIImagePickerControllerUserDidRejectItem" object:nil ];
}

- (void) removePhotoObservers {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

-(void)addCameraOverlay {
    if (self.cameraPicker) {
        self.cameraPicker.cameraOverlayView = self.myCameraOverlayView;
    }
}

-(void)removeCameraOverlay {
    if (self.cameraPicker) {
        self.cameraPicker.cameraOverlayView = nil;
    }
}