2012-08-04 90 views
1

基本上,通過使用相機應用程序自定義覆蓋圖,我想要拍攝多個圖像(在我的情況下爲5),只需按下一次「捕捉」按鈕即可。單擊'按鈕按下'後用相機捕捉多張圖像?

據我所知,下面的代碼:正在採取

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

結果在單個圖像中。有一種方法可以在按下一次按鈕後將此動作複製5次?實際上,這會在Camera +應用程序中實現「爆發」效果。

+2

您可以使用重複設置爲YES的NSTimer來觸發UIImagePickerController的takePicture方法。 – 2012-08-04 05:50:43

回答

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]; 
} 

} 
+3

kya setting lagaya hai老闆!!! – HarshIT 2013-07-19 10:21:27

+0

這不適用於ios 8 – bader 2016-01-14 00:32:54