UITableViewCell animations stop when UITableView is scrolling

Viewed 2828

I am making an 'event countdown' scene in my app that uses a UITableViewController to show a list of events that are happening in the future. In each cell I have a countdown timer that counts down the time until the event takes place.

enter image description here

I want to animate these countdown fields so they tick down in real time. I have achieved this animation already, but the problem is that when the user scrolls the uitableview the animation pauses until the user releases the scroll. I want the animations to continue even when scrolling.

The way I'm animating is by calling [self.tableview reloadData] on a NSTimer every 0.25s (I know this isn't the most efficient method - this was more testing the animation itself). I have also tried running an NSTimer calling view updates within the UITableViewCell itself - but still have the animation pauses when scrolling.

Anyone know a setting or alternative way of calling the animation that will keep it going whilst scrolling?

2 Answers

I am guessing you are using views to store your countdown data. Instead create a model for countdown, it could be initialized with a start date(NSDate) and a duration(NSTimeInterval). Then instead of your views update those Countdown objects according to timer. When a tableview cell becomes visible in the view, it will load data from the corresponding Countdown object and everything should run smoothly.

Related