2012-05-30 52 views
5

我希望我的应用只使用前置摄像头。所以我实现了下面的代码。UIImageViewController每次打开相机时都不会使用cameraDevice

if ([UIImagePickerControllerisCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) { 
    self.imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront; 
} 

这是第一次打开相机(它使用前置摄像头)。但是,如果我取消照片,然后重新进入相​​机,它将使用后置相机。

每一次取消/重新进入摄像头,可以前后摄像头之间切换...

有什么我失踪?

回答

0
Tr this code .I used this code and it is working fine .Use this code either in button action or viewwillappear or viewdidload and dismiss the camera view properly 
    imgPicker =[[UIImagePickerController alloc] init]; 
    imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    imgPicker.cameraDevice=UIImagePickerControllerCameraDeviceFront; 
    imgPicker.showsCameraControls = YES; 
    imgPicker.allowsEditing = YES; 
    imgPicker.delegate=self; 
    [self presentViewController:imgPicker 
         animated:NO completion:nil]; 
+0

工程就像一个魅力 – Ruban

0

我有同样的问题,并通过包括呼叫自动释放到分配的UIImagePickerController如下所示解决了我的情况的问题

的UIImagePickerController * CameraUI的= [[[的UIImagePickerController页头] INIT]自动释放]。

+1

我不能autorelease,因为我使用ARC。 – TrentEllingsen

相关问题