我的自定义相机覆盖上有一个按钮,可以调用此方法:
- (void) changeFlash:(id)sender
{
//UIImagePickerControllerCameraFlashModeOff = -1,
//UIImagePickerControllerCameraFlashModeAuto = 0,
//UIImagePickerControllerCameraFlashModeOn = 1
NSLog(@"before %d", self.picker.cameraFlashMode);
switch (self.picker.cameraFlashMode) {
case UIImagePickerControllerCameraFlashModeAuto:
[(UIButton *)sender setImage:[UIImage imageNamed:@"flashOn"] forState:UIControlStateNormal];
self.picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
break;
case UIImagePickerControllerCameraFlashModeOn:
[(UIButton *)sender setImage:[UIImage imageNamed:@"flashOff"] forState:UIControlStateNormal];
self.picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
break;
case UIImagePickerControllerCameraFlashModeOff:
[(UIButton *)sender setImage:[UIImage imageNamed:@"flashAuto"] forState:UIControlStateNormal];
self.picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
break;
}
NSLog(@"after %d", self.picker.cameraFlashMode);
}
self.picker.cameraFlashMode 在更改前后始终为 0。我究竟做错了什么?
此外,闪光灯从不工作,即使它据说卡在 UIImagePickerControllerCameraFlashModeAuto 中。