以编程方式拍照而无需用户交互

时间:2014-08-28 12:07:40

标签: ios iphone camera uiimagepickercontroller

如何在没有用户交互的情况下拍照或不显示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"];
}

我知道这样我可以自动拍照但我是如何完成的?

1 个答案:

答案 0 :(得分:5)

您可以使用takePicture上的UIImagePickerController方法以编程方式拍照。

但我建议使用AVFoundation创建自己的图片捕获。