我有iPhone应用程序,该应用程序将相机与自定义 View 叠加在一起。
我有一个按钮可以在相机闪光灯模式之间切换,这是代码
switch ([self.imagePickerController cameraFlashMode]) {
case UIImagePickerControllerCameraFlashModeAuto:
[self.imagePickerController setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
return @"On";
break;
case UIImagePickerControllerCameraFlashModeOn:
[self.imagePickerController setCameraFlashMode:UIImagePickerControllerCameraFlashModeOff];
return @"Off";
break;
case UIImagePickerControllerCameraFlashModeOff:
[self.imagePickerController setCameraFlashMode:UIImagePickerControllerCameraFlashModeAuto];
return @"Auto";
break;
default:
break;
}
这是我的问题:在iOS 7.0x上可以正常工作,但是在iOS 7.1中,无论其实际状态如何,cameraFlashMode属性都将返回UIImagePickerControllerCameraFlashModeAuto。
闪光灯模式确实会改变,但是我没有得到任何指示。
有什么线索吗?
谢谢
最佳答案
我这样解决了:
@property (nonatomic) NSInteger flashMode;
if (_flashMode == UIImagePickerControllerCameraFlashModeAuto)
{
_flashMode = UIImagePickerControllerCameraFlashModeOff;
}
else if (_flashMode == UIImagePickerControllerCameraFlashModeOff)
{
_flashMode = UIImagePickerControllerCameraFlashModeOn;
}
else if (_flashMode == UIImagePickerControllerCameraFlashModeOn)
{
_flashMode = UIImagePickerControllerCameraFlashModeAuto;
}
_cameraPicker.cameraFlashMode = (UIImagePickerControllerCameraFlashMode)_flashMode;
关于iOS 7.1 imagePicker CameraFlashMode不指示闪光灯状态,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22457097/