While a UIScrollView (or a derived class thereof) is scrolling, it seems like all the NSTimers that are running get paused until the scroll is finished.
--
You have to run another thread and another run loop if you want timers to fire while scrolling; since timers are processed as part of the event loop, if you're busy processing scrolling your view, you never get around to the timers. Though the perf/battery penalty of running timers on other threads might not be worth handling this case.
An easy & simple to implement solution is to do:
NSTimer *timer = [NSTimer timerWithTimeInterval:...
target:...
selector:....
userInfo:...
repeats:...];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
本文探讨了当使用UIScrollView滚动时,如何在iOS应用中继续运行定时器,提出了一种易于实现的解决方案:将定时器添加到主线程的运行环中。避免了由于UI线程被占用导致的定时器暂停问题。


被折叠的 条评论
为什么被折叠?



