I'm using the Facebook Pop library to bounce a view every time something happens in my app. The problem is that the animation works only on the 1st occurrence.
It is easily reproducible with this snippet
- (IBAction)buttonAction:(id)sender
{
POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
sprintAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
sprintAnimation.springBounciness = 20.f;
[self.shakeView pop_addAnimation:sprintAnimation forKey:@"springAnimation"];
}
The 1st time you tap the button, shakeView
is animated correctly but not on the taps after.
I tried removing all animation using [self.shakeView pop_removeAllAnimations]
before adding a new one but it doesn't help.
I think I missed something in the Pop usage.
Ok I found the problem. The solution is to set the removedOnCompletion
to NO
as follows:
- (IBAction)buttonAction:(id)sender
{
POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
sprintAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
sprintAnimation.springBounciness = 20.f;
sprintAnimation.removedOnCompletion = NO;
[self.shakeView pop_addAnimation:sprintAnimation forKey:@"springAnimation"];
}