Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TableView interaction blocking animations in cells

I have a progress indicator in a tableview cell that does not update its progress while the user interacts with the tableview. When the interaction stops the indicator jumps to where it should be.

How can this be avoided so that the animations continue even if the user is scrolling the tableview?

Can they be added to a runloop? If both the interaction and the animating needs to happen on the main thread, what work around can be done?

like image 308
some_id Avatar asked Dec 29 '25 17:12

some_id


1 Answers

First, you should make sure you really do want those progress indicators to update - The default behavior with UIScrollView type classes when scrolling is to pause any UI updates within them to keep things responsive. I've found things like scrolling speed can degrade surprisingly quickly whenever I try to do anything extra, especially on older devices.

Warnings aside, how do we do this? Well it looks like this question has a solution for you. A brief summary is:

  • Scrolling puts the runloop in UITrackingRunLoopMode
  • Your update code is not triggering while the runloop is in this mode
  • Solution: Have an NSTimer trigger your progress indicator updates, run that timer in NSRunLoopCommonModes so it will still fire while scrolling.

That's it. UIView updating is not the issue while scrolling, running the code that triggers the update is. By using a timer that is 'scroll-proof', your indicators should update just fine. There is some good example code at the linked question, so do click through to read!

like image 165
redlightbulb Avatar answered Jan 01 '26 07:01

redlightbulb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!