Similar to SO question ref: Why does UIView:animateWithDuration complete immediately? however, my code is using [UIView beginAnimation], etc.
I have essentially this:
[UIView beginAnimation ...];
[UIView setAnimationDelay: 0.0];
[UIView setAnimationDuration: 1.25];
animatedImage.transform = "scale-up transform";
[UIView setAnimationDelay: 1.25]
[UIView setAnimationDuration: 0.50];
animatedImage.transform = "scale-down transform";
[UIView commitAnimation];
The image immediately jumps to the scale-up size, then 1.25 seconds later it animates nicely to the "scale-down" size. If I chain more sequences, they all work correctly, except the first one.
When you put animations in the same beginAnimation zone, they'll animate at the same time.
By calling [UIView setAnimationDelay: 1.25], you're only overwriting your earlier [UIView setAnimationDelay: 0.0].
So what happens, is that the UIView is told to scale both up and down simultaneously. I guess since you tell it to scale both up and down, it simply skips the to the last of the animations, but you did tell it to scale up, so it does that without animating.
I suggest using the block syntax in stead, it allows you to do things after an animation completes:
[UIView animateWithDuration:1.25
animations:^{animatedImage.transform = "scale-up transform";}
completion:^(BOOL finished)
{
[UIView animateWithDuration:1.25
animations:^{animatedImage.transform = "scale-down transform";}
];
}
];
The code in the completion block (the ^{code} constructions are called 'blocks') is what happens after the first animation. You can keep chaining this for as many animations as you like.
(BOOL finished) is a parameter passed along with the block. It tells if the animation was really finished. If NO, your animation was interrupted.