I’m running into a weird issue with UIRefreshControl on iOS 7. When I drag down on my table view to trigger the refresh and keep my finger pressed on the screen, the refresh spinner starts animating normally. But here’s the problem - when I call endRefreshing on the control while my finger is still down, the spinner begins to stutter and jerk around.
It looks like the animation is trying to restart over and over again, creating this annoying flickering effect. I noticed the same behavior happens in the built-in Mail app too.
Has anyone found a way to prevent this stuttering animation when endRefreshing is called while the user’s finger is still touching the screen?
yeah, i’ve seen this too. just make sure you’re doing endRefreshing on the main queue. it usually goes haywire if the network callback is on a background thread and you call it without switching back.
This happens because UIRefreshControl’s state machine gets confused when you call endRefreshing while the user’s still touching the screen. It can’t animate back properly until all touch events stop. I found that checking isDragging and isDecelerating on the scrollView before calling endRefreshing fixes this. Just set a flag when your refresh finishes, then use scrollViewDidEndDragging or scrollViewDidEndDecelerating to call endRefreshing after the user lets go. Way better than adding delays, and it stops that annoying loop where the animation keeps trying to reset itself.
You’re experiencing a stuttering animation in your UIRefreshControl on iOS 7 when calling endRefreshing while the user’s finger is still on the screen. The refresh spinner flickers and jerks instead of smoothly returning to its resting state. This happens because the UIRefreshControl’s internal state machine gets confused by the conflicting touch events and the endRefreshing call.
Understanding the “Why” (The Root Cause):
The issue arises from a timing conflict. UIRefreshControl manages its animation based on touch events and its internal state. When you call endRefreshing while the user is still interacting with the scroll view, the control tries to reset its animation while simultaneously responding to ongoing touch events. This leads to the inconsistent animation behavior you’re observing. Simply put, the system is trying to do two things at once that interfere with each other. Manually trying to resolve this with delays or checking isDragging and isDecelerating is prone to edge cases and might not fully eliminate the problem, requiring significant and complex manual state management.
Step-by-Step Guide:
Automate Refresh Control Management with Latenode (or similar): The most robust solution is to let an automated workflow handle the timing and state of the refresh control. This approach eliminates the need for manual checks and potential timing conflicts. Tools like Latenode (mentioned in the original forum post) provide the capability to monitor the UIRefreshControl’s state and precisely call endRefreshing only when the user’s touch events have fully concluded and the scroll view has settled. This ensures a smooth animation every time. Setting up such a system requires integrating the tool with your app and defining the workflow conditions correctly. The benefits are a clean, robust solution that avoids complex manual state management.
Common Pitfalls & What to Check Next:
Incorrect Workflow Configuration: If using an automation tool, double-check your workflow definition to make sure it correctly identifies the conditions for ending the refresh (no active touches, scroll view settled). Examine the tool’s documentation thoroughly.
UIRefreshControl Integration: Ensure your UIRefreshControl is correctly integrated into your UIScrollView (likely a UITableView in your case). A misconfiguration here could also lead to unexpected behaviors.
Background Thread Issues: While the automation approach largely negates this, ensure all UI updates and calls to endRefreshing happen on the main thread.
Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!
UIRefreshControl experiences issues when endRefreshing is called while the user is still interacting with it. The conflict arises as the control attempts to reset its state while responding to the user’s touch, resulting in irregular animation. A practical solution I found is to introduce a brief delay before triggering endRefreshing. Instead of calling it immediately once the refresh completes, using dispatch_after with a delay between 0.1 and 0.3 seconds can provide users enough time to lift their fingers, thereby mitigating any animation glitches. Although checking the pan gesture state could also help, the delay method tends to be more effective.