iOS: UIScrollView pauses NSTimer while scrolling

StackOverflow http://stackoverflow.com/a/7059499

 

Question:I have a UIScrollView that has a series of labels which are rapidly updating numbers (every .06 seconds). While the scroll view is moving, however, the NSTimer is paused and does not continue until after the scrolling and the elastic animation have finished.

How can I avoid this and have the NSTimer run regardless of the state of the scroll view?

 

Anwser:An easy way to fix this is adding your NSTimer to the mainRunLoop.

[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

To remove a timer from all run loop modes on which it is installed, send an invalidate message to the timer.

posted @ 2014-06-28 04:07  有妄想症的猫zz  阅读(490)  评论(0编辑  收藏  举报