我想使用前置摄像头在没有任何用户交互的情况下在 iOS 中拍摄照片。谁能告诉我如何做到这一点?
我takePicture
在课堂上使用了该函数,UIImagePickerController
但它不起作用,因为委托方法(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)
信息从未被调用:
-(void)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
//Use camera if device has one otherwise use photo library
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
[imagePicker setDelegate:self];
//Show image picker
[imagePicker takePicture];
}
谁能告诉我正确的方法来做到这一点?