Search code examples
iosiphonecamerauiimagepickercontroller

Programmatically Take Picture Without User Interaction


How do I take Picture without User Interaction or without presenting ImagePickerController

  UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        [imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
    }

    // image picker needs a delegate,
    [imagePickerController setDelegate:self];

    // Place image picker on the screen
    [self presentModalViewController:imagePickerController animated:YES];

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    _myImageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

I know this way I can take picture but automatically How I do accomplish?


Solution

  • You can use the takePicture method on UIImagePickerController to take a picture programmaticly.

    But I suggest to use AVFoundation to create you onw image capture.