将 Timerinterval 设置得很快,然后逐渐减慢
我有以下代码:
xx=0.50;
[NSTimer scheduledTimerWithTimeInterval:xx target:self selector:@selector(ontimer:) userInfo:nil repeats:YES];
-(void)ontimer
{
xx=xx+0.05;
NSTimeInterval dt = [timer timeInterval];
// do something
}
我想调用 ontimer 0.50 然后 0.55 然后 0.60 &很快。这意味着先快然后逐渐慢。
问题是每次 Time ontimer 都会被调用 0.50 秒。
提前致谢。
i have the following code:
xx=0.50;
[NSTimer scheduledTimerWithTimeInterval:xx target:self selector:@selector(ontimer:) userInfo:nil repeats:YES];
-(void)ontimer
{
xx=xx+0.05;
NSTimeInterval dt = [timer timeInterval];
// do something
}
I want to call ontimer for 0.50 then 0.55 then 0.60 & soon. that means First Fast then gradually slow down.
The Problem is each Time ontimer will be called for 0.50 seconds.
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,当计时器启动时,您无法调整 timeInterval,因此您必须每次都更改 fireDate 。像这样:
afaik you can't adjust the timeInterval when a timer has been started, so you have to change the fireDate each time. Like this:
您是否尝试过将时间变量设置为静态?
Have you tried setting your time variable to static?