1

I am trying to create a camera overlay that can recognize swipe gestures to push to other views.

I am wondering if I can still use the UIImagePicker or if I have to use the AVCaptureSessionManager.

Also i would prefer to create the overlay view in the story board is there a way to do that? can I select a view inside the storyboard controller be the camera overlay and simply present the UIImagePicker on view did load?

Santiago
  • 1,984
  • 4
  • 19
  • 24

1 Answers1

1

I've never used the Storyboard to create a camera overlay, but I have created a xib which works fine. You can create the overlay viewController in the normal (xib) way, complete with gesture recognizers, then you can handle them directly in that VC or use a delegate (most likely the VC which presented the camera).

Some code -

-(void)setupCamera
{
    self.picker = [[UIImagePickerController alloc] init];

    _picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    _picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

    self.overlay = [[OverlayViewController alloc] init];
    _overlay.delegate = self;

    _picker.cameraOverlayView = _overlay.view;
    _picker.delegate = self;

    [self presentViewController:self.picker animated:YES completion:nil];
}

The overlay -

-(id)init
{
    self = [super initWithNibName:@"OverlayViewController" bundle:nil];

    if (self)
    {
        // set up stuff
    }
    return self;
}

... & some code which handles the swipe -

-(IBAction)swipe:(UISwipeGestureRecognizer *)sender
{
    // swipe stuff
    [self.delegate doSwipeStuff]; // if you want the delegate to handle it
}

Hope this helps.

SomaMan
  • 4,127
  • 1
  • 34
  • 45
  • thanks for the help so far! However I am having trouble setting the delegate of the OverlayViewController. What I have so far is an OverlayViewController with an .xib file containing gesture recognizer and a take_photo button. However when I setupCamera on my CameraViewController I can't assign the delegate of OverlayViewController to be the current CameraViewController which will respond the take_photo button / the gesture_swipe. I get the error: Property delegate not found on OverlayViewController... – Santiago Jul 25 '13 at 06:17
  • Sounds like you need to do some reading up on the use of delegates - it's pretty fundamental to a lot of stuff (saying that, a lot of the new frameworks use blocks instead, but delegates still play a very important role) - have a look at Ray Wenderlich's tutorial - http://www.raywenderlich.com/forums/viewtopic.php?f=10&t=3265 – SomaMan Jul 30 '13 at 07:54