XTLoopScroll icon indicating copy to clipboard operation
XTLoopScroll copied to clipboard

关于timer的一个小细节

Open wzqcongcong opened this issue 9 years ago • 3 comments

感觉_timerOverflow是不是可以省掉啊,直接在resumeTimerWithDelay函数里面用[_timerLoop setFireDate:[NSDate dateWithTimeIntervalSinceNow: _durationOfScroll]]来设定下次的触发时间?

wzqcongcong avatar Nov 03 '15 10:11 wzqcongcong

谢谢你的提议, 但是这个我试过, 同一个作用域里不能设自两次FireDate, 后面设的无效, 所以会用了两个定时器控制, 当然, 如果你还有更好的做法, 随时通知我

Akateason avatar Nov 03 '15 14:11 Akateason

我测试了下你说的问题,连着调用2次,比如:[self.timer setFireDate:[NSDate distantFuture]]; [self.timer setFireDate:[NSDate dateWithTimeIntervalSinceNow:3]];,后面设置的会生效的,3s后就触发了。不知道你指的是这样吗?

wzqcongcong avatar Nov 04 '15 08:11 wzqcongcong

如果你多次触发这个逻辑, 会一直启动timer的, 不知道你有没有在项目demo里面调试过, 我一直滑动去调试, 过了几秒之后, scrollview会连续滚动多次, 你可以在我的demo里替换试试看

Akateason avatar Nov 05 '15 02:11 Akateason