I have a UIView
on which I apply a UIPushBehavior
of mode UIPushBehaviorModeInstantaneous
. What is the easiest way to know when the pushed UIView
stops moving?
Asked
Active
Viewed 583 times
1

Rafał Sroka
- 39,540
- 23
- 113
- 143
1 Answers
4
In your view controller, set the delegate property of your UIDynamicAnimator to be self. Then you will receive dynamicAnimatorDidPause notifications when the animation stops. Define a dynamicAnimatorDidPause function to handle the event. See the Xcode documentation on UIDynamicAnimator.

BobSnider
- 116
- 4
-
It looks like this is the only option. Thanks. – Rafał Sroka Feb 21 '14 at 21:26
-
It's not sp much "the only option" ... it's .... how you do it :) How else did you think you could be notified, other than, a delegate?! – Fattie Jun 23 '14 at 07:19
-
This doesn't work for me, I receive the notification up to seconds after the animation stops - maybe because it keeps oscillating for a while with an imperceptibly tiny amplitude? – bcattle Sep 18 '14 at 05:25
-
You are correct, bcattle. These dynamic animations sometimes take a long time to "stop" as iOS sees it. You can add more damping. Someone may know (but I don't) if there is a way to add some hysteresis to the animation, so you could tell it to stop at some threshold velocity. I guess you could set a timer and stop it after a time limit, but this is getting away from simple. – BobSnider Oct 21 '14 at 16:19