如何在没有用户交互的情况下拍照或不显示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"];
}
我知道这样我可以自动拍照但我是如何完成的?
答案 0 :(得分:5)
您可以使用takePicture
上的UIImagePickerController
方法以编程方式拍照。
但我建议使用AVFoundation
创建自己的图片捕获。