2014-01-15 108 views
1

夥計們。ioS7:從相機捕捉多個圖像並存儲在陣列

我試圖捕捉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]; 
    } 
} 

有誰知道發生了什麼?

在此先感謝!

回答

0

設置showsCameraControls = NO;

使用cameraOverlayView財產。

在您的相機按鈕的操作中調用takePicture方法。 不斷添加UIImage對象收到的方法

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
+0

感謝您的快速回復,Sarvjeet。對不起,我是一個初學者程序員的目標-c。你能以其他方式解釋嗎?謝謝你,朋友! –

+0

你可以在這裏閱讀https://developer.apple.com/library/ios/documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html –

相關問題