5

我希望我的应用只使用前置摄像头。所以我实现了以下代码。

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

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

每次取消/重新进入摄像头时,它都会在前后摄像头之间切换......

有什么我想念的吗?

4

2 回答 2

0

I was having the same problem and resolved the issue in my case by including autorelease on the call to allocate the UIImagePickerController as shown here

UIImagePickerController *cameraUI = [[[UIImagePickerController alloc] init] autorelease];

于 2012-06-01T20:37:48.290 回答
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];
于 2013-07-30T12:18:57.030 回答