I ran into that bug before
The problem is that no matter what the real flash state is in ios 7.1, it always returns UIImagePickerControllerCameraFlashModeAuto
. Funny thing is, if you set the flash mode to UIImagePickerControllerCameraFlashModeOff
, the flash will really be off, but if you ask the state, it will still be UIImagePickerControllerCameraFlashModeAuto
.
So I solved my problem by keeping my own "flashState". When, clicked, I manually change my own state and never trust the one sent back but the UIImagePickerController.
@property (nonatomic) UIImagePickerControllerCameraFlashMode flashMode;
when the button is clicked :
if (self.flashMode == UIImagePickerControllerCameraFlashModeAuto) {
//toggle your button to "on"
self.flashMode = UIImagePickerControllerCameraFlashModeOn;
}else if (self.flashMode == UIImagePickerControllerCameraFlashModeOn){
//toggle your button to "Off"
self.flashMode = UIImagePickerControllerCameraFlashModeOff;
}else if (self.flashMode == UIImagePickerControllerCameraFlashModeOff){
//toggle your button to "Auto"
self.flashMode = UIImagePickerControllerCameraFlashModeAuto;
}