Hi there I’m having some problems coding an animation for a UIView in my iPhone app. I’m trying to set an animation for the frame of the UIView after i updated the frame property. Here is the code.
//old frame values are: 0, 0, 15, 37
//set the frame for hiding the arrow
[arrow setFrame:CGRectMake(-15, 100, 15, 37)];
//Create an animation to let the arrow slide in the view.
[UIView beginAnimations:@"SlideInArrow" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:true];
[UIView setAnimationDuration:1.0];
[symbolArrow setFrame:CGRectMake(0, 100, 18, 37)];
[UIView commitAnimations];
this code is a part of a method i wrote. It will be fired when the user is pressing a button. i suggest, that the UI won’t update the new frame values to the object. Instead the animation uses the old values. Why is it so? Is there a way to get the view or the animation to get the new frame values?
You’re setting
animationBeginsFromCurrentState:, which explicitly tells the system to animate based on where the view currently is on the screen. At this point in time, the frame is still at {0,0} because the run loop hasn’t completed, so none of your previoussetFrame:transactions have been applied. First, take this line out, which may fix it by itself. If not, there are other ways to set thefromValuethe way you describe.The basic flow is odd, however. If the code is as you suggest, the arrow is on screen at {0,0}, and you’re going to make it vanish and slide back on. Is that really the animation you’re going for, or is there more animations that you’ve left out? What’s the full effect you’re trying to achieve?
Note that you have
arrowin one case andsymbolArrowin another, which I assume is a typo, but would definitely be a problem if these were different objects.