单按“按下”后,用相机拍摄多张图像?

时间:2012-08-04 05:37:58

标签: iphone ios xcode camera

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

我理解以下代码:

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

导致拍摄单张图像。有一种方法可以在按下一个按钮后将此操作复制5次吗?实际上,这将实现“爆发”。喜欢效果,就像在Camera + app中实现的那样。

1 个答案:

答案 0 :(得分: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];
}

}