ioS7:从相机捕获多个图像并以阵列形式存储

时间:2014-01-15 14:44:24

标签: ios objective-c

我正在尝试从iOS7中的相机捕获多个图像,当我捕获第一个图像并单击“使用照片”时,它将图像存储在didFinishPickingMediaWithInfo中的数组中。当相机再次出现时,我看到背景中的最后一张图像但我看不到相机的移动。我知道相机已启用,因为它正在搜索面孔。代码如下:

 - (IBAction)openTour:(id)sender
 {
      _counter=0;

      if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
      {
           UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
           imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
           imagePicker.showsCameraControls = YES;
           imagePicker.delegate = self;
           [self presentViewController:imagePicker animated:YES completion:nil];
           imagePicker = nil;
       }
 }

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:  (NSDictionary *)info
 {
     UIImage *image= [info objectForKey:UIImagePickerControllerEditedImage];

     [ _imageArray addObject:image ];

     _counter++;

     if ( _counter<5 )
     {
          [self dismissViewControllerAnimated:NO completion:nil];

          if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
          {
               UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
               imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
               imagePicker.showsCameraControls = YES;
               imagePicker.delegate = self;
               [self presentViewController:imagePicker animated:NO completion:nil];
               imagePicker = nil;
          }
     }
     else
     {
         [self dismissViewControllerAnimated:YES completion:nil];
     }
 }

有谁知道发生了什么事?

提前致谢!

1 个答案:

答案 0 :(得分:0)

设置showsCameraControls = NO;

使用cameraOverlayView属性。

在相机按钮的操作中调用takePicture方法。 继续添加方法

接收的UIImage对象
    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info