2014-12-03 48 views
0
-(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); 
     } 
    } 
}  

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

回答

0

试试这个,

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是你想拍摄照片的数量。

+0

/*我在询问有关在拍摄多张图像时同时保存图像的问题。那时我们不知道我们要拍多少张图片?此外,图像应该在图像上拍摄精确的图像。节省过程也适用于背景模式。你能帮我吗 */ – 2014-12-12 05:55:01