我希望我的应用只使用前置摄像头。所以我已经实现了以下代码。
if ([UIImagePickerControllerisCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
self.imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
第一次打开相机时(这是使用前置摄像头)。但如果我取消照片然后重新进入相机,则使用后置摄像头。
每次取消/重新进入相机时,它会在前后摄像头之间切换......
我有什么遗失的吗?
答案 0 :(得分:0)
我遇到了同样的问题并通过在调用中包含autorelease来解决问题,如此处所示分配UIImagePickerController
UIImagePickerController * cameraUI = [[[UIImagePickerController alloc] init] autorelease];
答案 1 :(得分: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];