I'm starting to learn how to use UIView animation. So I wrote the following lines:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationRepeatCount:2];
[UIView setAnimationRepeatAutoreverses:YES];
CGPoint position = greenView.center;
position.y = position.y + 100.0f;
position.x = position.x + 100.0f;
greenView.center = position;
[UIView commitAnimations];
In this case, the UIView (green box) moves back and forth 2 times. So far so good, BUT I found out that after a double transition the green box turned up to jump to the “new position” (position.x + 100.0f, position.y + 100.0f) instead of returning to its original position (position.x, position.y ) This makes the animation rather strange (for example, after the window returns to its original position caused by setAnimationRepeatAutoreverses, it returns to its new position within the last microsecond!)
What is the best way to get the green box NOT to move to the new position at the last minute?