iphoneiosavfoundationavcamcamera-overlay

Square Cam's View not shown cameraview


I refer the squareCam example of apple's development library it works fine.

But

When i try to change overlay image on one button click like this

square = [UIImage imageNamed:@"add"];
[self teardownAVCapture];
[self setupAVCapture];

on button click i use this code to change the image and show as overlay.

but i don't know what the problem is but i have to click twice to show the cameraview as first time it just shows black screen.

Help me please. Thanks in advance.


Solution

  • I got the error. Have to make some changes in the method below shown as I am uses ARC in iOS5.

    - (void)teardownAVCapture
    {
        [session stopRunning];
        session = nil;
        videoDataOutput = nil;
        dispatch_release(videoDataOutputQueue);
        [stillImageOutput removeObserver:self forKeyPath:@"capturingStillImage"];
        stillImageOutput = nil;
        previewLayer = nil;
        [previewLayer removeFromSuperlayer];
    }