我正在制作一个手电筒应用程序,但我遇到了问题
如何使用 uiswitch、uislder 和 nstimer 闪烁手电筒。
我在网上找到了一些东西,但我无法理解。
我已经完成了如何打开手电筒(LED),但我找不到如何闪烁它。另外,我不能很好地使用 NSTimer。
self.blinkTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES];
我在 Stack Overflow 中找到了这段代码,但这@selector(timerUpdate)
是个scheduledTimerWithTimeInterval:0.3
问题。
我的计划是
uislider 的值 --> scheduledTimerWithTimeInterval:(uislder 的值)
uiswitch --> 开始闪烁手电筒。
- (void)toggleFlashlight
{
}
- (IBAction)blink:(UISwitch *)sender {
}
- (IBAction)blinkspeed:(UISlider *)sender {
int progress = lroundf(sender.value);
self.blinksliderlabel.text = [NSString stringWithFormat:@"%dms", progress];
}
可悲的是,我不知道..如何在那里插入代码...请帮助:(