首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS中的摄像头多路图像捕获

iOS中的摄像头多路图像捕获
EN

Stack Overflow用户
提问于 2014-12-03 17:50:49
回答 1查看 1.1K关注 0票数 0
代码语言:javascript
复制
-(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);
        }
    }
}    

/*我写了这段代码。问题是当我尝试拍摄多张照片时,它显示“收到内存警告”,并且我的应用程序崩溃了。在此我尝试计数图像,同时它也计数“相机未就绪模式”,以便我拍摄的图像保存多次。如何解决此问题?*/

EN

回答 1

Stack Overflow用户

发布于 2014-12-03 18:16:57

尝尝这个,

代码语言:javascript
复制
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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27268421

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档