Hi.
I have some simple code to move a view (called theView) down when a button is pressed. What im trying to figure out is how to move it back up if the same button is pressed again.
Here is the code:
Code:
-(IBAction)move {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
CGPoint pos = theView.center;
pos.y += 200.0f;
theView.center = pos;
[UIView commitAnimations];
}
Im thinking it could look something like this:
Code:
-(IBAction)move {
BOOL reverse = NO;
if (reverse = NO);{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
CGPoint pos = flap.center;
pos.y += 200.0f;
flap.center = pos;
[UIView commitAnimations];
reverse = YES;
}
if (reverse = YES);{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
CGPoint pos = flap.center;
pos.y -= 200.0f;
flap.center = pos;
[UIView commitAnimations];
reverse = NO;
}
}
but this runs the first part (moves it down) and then moves it back up.
What have i done wrong? (Im new to iPhone development so its probably something really silly and easy
)