iOS中的相机多图像捕捉

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { if ([multipleCapture isOn]) { images=info[UIImagePickerControllerOriginalImage]; currentDate=[NSDate date]; myString=[dateFormatter stringFromDate:currentDate]; customText=imagetext.text; saveImage.dateTime=myString; saveImage.imageName=info[UIImagePickerControllerOriginalImage]; saveImage.customText=customText; [imageArray addObject:saveImage]; [imageArray sortUsingDescriptors:sortDescriptors]; if ([imageArray count] == 1) { UIGraphicsBeginImageContext(images.size); myString=[[imageArray objectAtIndex:0]valueForKey:@"dateTime"]; [images drawInRect:CGRectMake(0, 0, images.size.width, images.size.height)]; NSDictionary* attributes = @{NSFontAttributeName : [UIFontboldSystemFontOfSize:75],NSStrokeColorAttributeName :[UIColor blackColor],NSForegroundColorAttributeName : [UIColor yellowColor],NSStrokeWidthAttributeName : @-2.0}; [myString drawAtPoint:CGPointMake(120,70)withAttributes:attributes]; [customText drawAtPoint:CGPointMake(870, 70)withAttributes:attributes]; newImage= UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(newImage,self,@selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil); } } } 

/ *我在这个代码上工作。 问题是当我尝试使多个镜头显示“收到内存警告”,我的应用程序崩溃。 在这个我试图计数的图像,在同一时间它也计数“相机没有准备好模式”也为了我的拍摄的图像保存多次。 我该如何解决这个问题? * /

尝试这个,

 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<PhotoCount) { [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]; } } 

PhotoCount是您想要拍摄的照片数量。