我有一个旋钮可以IBAction
调节.timeInterval
NSTimer
但我找不到一种方法让计时器在调整timeInterval
. 我想这是因为我不断地使计时器无效并重新实例化,对吧?
有没有办法让它顺利工作 - 以便计时器将随着旋钮运动加速/减速?
-(IBAction)autoSpeed:(UISlider *)sender
{
timeInterval = (60/sender.value) / 4;
if (seqState){
[self changeTempo];
}
[self displayBPM:[sender value]:[sender isTouchInside]];
}
-(void) changeTempo
{
if (repeatingTimer!= nil) {
[repeatingTimer invalidate];
repeatingTimer = nil;
repeatingTimer = [NSTimer scheduledTimerWithTimeInterval: timeInterval target:self selector:@selector(changeAutoSpeedLed) userInfo:nil repeats:YES];
}
else
repeatingTimer = [NSTimer scheduledTimerWithTimeInterval: timeInterval target:self selector:@selector(changeAutoSpeedLed) userInfo:nil repeats:YES];
}