我使用scheduleTimerWithTimeInterval:每隔N秒执行一次动画。
在某些情况下,我想重新安排时间,因此N重新开始重新计算。
schduleTimerWithTimeInterval: 5
5秒后执行操作
5秒后执行操作
从最后一次操作开始经过了2秒,然后X发生了一些事情
从X开始5秒,执行操作(即不是自上次执行操作以来的5秒)
5秒后执行操作
5秒后执行操作
那么,当X发生时,是否有可能重置scheduleTimerWithTimeInterval?
发布于 2013-07-10 00:41:32
所以就像这样:
self.timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(takeAShot) userInfo:nil repeats:YES];
然后当x出现时:
[self.timer invalidate];
self.timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(takeAShot) userInfo:nil repeats:YES];
或具有重复和非重复定时器的任意数量的方式
https://stackoverflow.com/questions/17553569
复制相似问题