Search code examples
iosuiimagepickercontrollercamera-overlay

UIImagePickerController cameraOverlay behind shutter


Can not find any definitive answer, but it looks like it is not possible. I am just displaying a frame image as an overlay to guide the user where the photo should be positioned. However the frame appears on top of the shutter on the opening and closing animation. Is there any (app store compliant) way to make the overlay view appear behind the shutter animation?

Also, when to remove/hide the overlay after the user pressed the take photo button? I have allowsEditing enabled, so I don't want the frame overlay being shown when editing the image. I can not figure how to capture that event.

Thanks


Solution

  • On the iPad this problem doesn't exist, and the overlay view is behind the shutter animation by default. But on the iPhone, the overlay appears at front.

    EDIT:

    I've found a solution that worked for me.

    You have to set your overlay view as a subview in this method:

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
        if (!viewController)
            return;
    
        UIView* controllerViewHolder = viewController.view;
        UIView* controllerCameraView = [[controllerViewHolder subviews] objectAtIndex:0];
        UIView* controllerPreview = [[controllerCameraView subviews] objectAtIndex:0];
        [controllerCameraView insertSubview:self.overlayView aboveSubview:controllerPreview];
    }
    

    Hope it helps

    Original source: http://www.alexcurylo.com/blog/2009/06/18/uiimagepickercontroller-in-3-0/