1

基本上,通过使用相机应用程序的自定义叠加层,我想要拍摄多张图像(在我的情况下为 5),只需按一下“捕获”按钮。

我了解以下代码:

- (void)takePicture:(id)sender
{
    self.pictureButton.enabled = NO;
    [self.delegate takePicture];
}

导致拍摄单个图像。按下一个按钮后,有没有办法让这个动作重复 5 次?实际上,这将实现类似“突发”的效果,就像在 Camera+ 应用程序中实现的那样。

4

1 回答 1

7

试试这个代码,它从相机拍摄 5 张照片并存储在一个数组中。根据需要使用。

int counter;
NSMutableArray * imageArray;

-(void)takePicture
 {
       counter=0;
       UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
UIImage *image= [info objectForKey:UIImagePickerControllerEditedImage];

[imageArray addObject:image];
counter++;  
if (counter<5)
{
    [self dismissModalViewControllerAnimated:NO];
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    [imagePicker setDelegate:self];
    [self presentModalViewController:imagePicker animated:NO];
    [imagePicker release];
}
else
{
    [self dismissModalViewControllerAnimated:YES];
}

}
于 2012-08-04T05:58:39.063 回答