允许使用UIImagePickerController捕获照片,直到点击取消按钮
我正在实施相机功能,我需要允许用户拍摄尽可能多的照片并存储它们。 我能够做到这一点,但一次只能有一张照片! 用户必须再次点击拍照按钮才能打开相机并拍摄照片。 我试图在保存照片后不关闭UIImagePickerController,但它不起作用! 请参阅我的以下代码。 有人能告诉我如何让用户继续拍照,直到他们点击UIImagePickerController上的取消按钮。 谢谢。
- (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];
}
看看这个主题,它可以帮助你找到你要找的东西。
链接地址: http://www.djcxy.com/p/68377.html上一篇: Allow capturing photos using UIImagePickerController until cancel button clicked
下一篇: iOS: how to change between views after picking a photos?