嗨,我正在为 iPhone 使用 Objective C 中的手电筒应用程序,我有一些基本功能,例如 LED 调光滑块和打开和关闭手电筒的按钮,但我想添加第二个滑块以添加频闪灯效果滑动滑块会增加闪烁的频率。
我已经尝试了我能想到的任何东西,但没有任何效果:/
这是我正在使用的代码的一部分:
-(IBAction)torchOn:(id)sender;
{
onButton.hidden = YES;
offButton.hidden = NO;
onView.hidden = NO;
offView.hidden = YES;
if([self.flashlight isTorchAvailable] && [self.flashlight isTorchModeSupported:AVCaptureTorchModeOn])
{
BOOL success = [self.flashlight lockForConfiguration:nil];
if (success)
{
[self.flashlight setTorchMode:(AVCaptureTorchModeOn)];
[self.flashlight unlockForConfiguration];
}
}
}
- (IBAction)intensitySliderValueChanged:(UISlider*)sender {
if(sender.value == 0 || sender.value > 1) return;
if([self.flashlight isTorchAvailable] && [self.flashlight isTorchModeSupported:AVCaptureTorchModeOn])
{
BOOL success = [self.flashlight lockForConfiguration:nil];
if (success)
{
[self.flashlight setTorchModeOnWithLevel:sender.value error:nil];
[self.flashlight unlockForConfiguration];
}
}
}
我知道这对于理解我的问题并不是特别有用,但是如果你们中的任何人有解决方案,我将非常感激!