IPhone SDK - How to take a picture with a custom camera view?

I want to remove the shutter as soon as the user types the screen. I have a working code to display the camera in full screen. How can I call the shutter by touch?

- (IBAction) takePicture
{
    if (! self.imgPicker) {
        self.imgPicker = [[UIImagePickerController alloc] init];
        self.imgPicker.allowsEditing = NO;
        self.imgPicker.delegate = self;
    }

    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
    {
        self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        self.imgPicker.showsCameraControls = NO;
        self.imgPicker.wantsFullScreenLayout = YES;

        CGAffineTransform cameraTransform = CGAffineTransformMakeScale (1.132, 1.132);
        self.imgPicker.cameraViewTransform = cameraTransform;

        UIView * headsUpView = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 480, 320)];

        [self.imgPicker setCameraOverlayView: headsUpView];
    } else {
        NSLog (@ "Camera not available.");
        self.imgPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;  
    }

    [self presentModalViewController: self.imgPicker animated: YES];
}
+3
source share
1 answer

You must use the takePicutre method and then detect any touch on the screen.

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/instm/UIImagePickerController/takePicture

-

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = [[event allTouches] anyObject];
    self.imgPicker.takePicture;
}
+2

Source: https://habr.com/ru/post/1755196/


All Articles