The UIImageViewControllerDevice camera is not used every time the camera is opened

I want my application to use only the front camera. So I executed the following code.

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

This works the first time I open the camera (it uses the front camera). But if I canceled the photo, and then again enter the camera, it uses a rear view camera.

Each time you cancel / re-enter the camera, it switches between the front and rear cameras ...

Is there something I am missing?

+5
source share
2 answers
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
source

, , UIImagePickerController, .

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

0

All Articles