[英]Allow capturing photos using UIImagePickerController until cancel button clicked
I am implementing camera functionality where I need to allow users to take photos as many they like and store them. 我正在实现相机功能,我需要允许用户拍摄任意数量的照片并进行存储。 I am able to do this but one photo at a time! 我能够做到这一点,但一次只能一张照片! USer has to click again takePhoto button to open camera and capture photo. 用户必须再次单击takePhoto按钮以打开相机并捕获照片。 I am trying to not dismiss UIImagePickerController after photo has been saved but it's not working! 保存照片后,我试图不关闭UIImagePickerController,但是它不起作用! Please see my following code. 请查看我的以下代码。 Could someone please tell me how could I allow users to keep taking picture until they click cancel button on UIImagePickerController. 有人可以告诉我如何允许用户继续拍照,直到他们单击UIImagePickerController上的“取消”按钮为止。 Thanks. 谢谢。
- (IBAction)takePhoto:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
[self presentModalViewController:imagePicker animated:YES];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image, 1);
[imageData writeToFile:[delegate filePath:imageName] atomically:YES];
}
[picker dismissModalViewControllerAnimated:YES]; --> If I remove this then Camera stays open but Photo click button gets disabled! If I don't remove this it dismiss the camera.
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
看一下这个线程,它可能会帮助您找到所需的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.