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. I am trying to not dismiss UIImagePickerController after photo has been saved but it's not working! 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. 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];
}

看看这个主题,它可以帮助你找到你要找的东西。

链接地址: http://www.djcxy.com/p/68378.html

上一篇: 如何在UIImagePickerController中禁用视频选择按钮

下一篇: 允许使用UIImagePickerController捕获照片,直到点击取消按钮