我有一个计时器触发转到void语句。其中有另一个计时器。我想暂停那个开火或关闭的那个然后恢复它。
movement3 = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(jone) userInfo:nil repeats:NO];
- (void)jone{
[jumperguy setImage:[UIImage imageNamed:@"jumperguy_a_a3.png"]];
movement4 = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(jtwo) userInfo:nil repeats:NO];
}
答案 0 :(得分:0)
您只能invalidate
NSTimer
个对象才能停止它。您可以使用两种方法,例如:
-(void) pauseTimer:(NSTimer *) timer {
[timer invalidate];
timer = nil;
}
-(void) resumeTimer:(NSTimer *) timer {
timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(jone) userInfo:nil repeats:NO];
}