我有iPhone应用程序覆盖相机与自定义视图.
我有一个按钮来切换相机闪光模式,这是代码
我有一个按钮来切换相机闪光模式,这是代码
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;