2014-12-03 99 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