开发者

UIImagePickerController not working with front (or rear) camera

开发者 https://www.devze.com 2023-01-19 23:20 出处:网络
iOS Gurus: I am trying to use the build in camera app to take pictures for my app to use. I\'ve used following standard code:

iOS Gurus:

I am trying to use the build in camera app to take pictures for my app to use. I've used following standard code:

To invoke the camera app:

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePicker animated:YES];

To process the image once user takes the picture and presses 'use':

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

   image = (UIImage *)
        [info valueForKey:UIImagePickerControllerOriginalImage];

   imageView.image = image;
}

Now the problem is this:

With the above code, the REAR camera will be activated by default, which is fine. Picture taken by the rear camera will show up properly in imageView. However if I switch to FRONT camera using the 'on screen switcher' with the built in camera app, the picture taken will not show up in imageView.

With the code below, I can activate the FRONT camera by default when the built-in camera app starts:

imagePicker.cameraDevice = UIImag开发者_运维知识库ePickerControllerCameraDeviceFront;

Now the reverse happens: picture taken by FRONT camera will show up, not the one by the REAR camera. Very frustrating.

Any help will be greatly appreciated.

Thunder


The problem went away after I rebooted the device... :)

0

精彩评论

暂无评论...
验证码 换一张
取 消