iphone: repeating a transformation
- by gonso
Hi
I'm trying to represent a view that rotates on the iphone screen. I have a button and when you press it, the view rotates 180 degrees.
My problem is that this only works the first time.
Here is the code:
-(IBAction) flip:(id)sender{
CGAffineTransform transform; //the transform matrix to be used below
//BEGIN ANIMATIONS
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
//animate
if (flag){
transform = CGAffineTransformMakeRotation( RADIANS(180) );
} else {
transform = CGAffineTransformMakeRotation( RADIANS(-180) );
}
flag = !flag;
transform = CGAffineTransformTranslate(transform, 0, 0);
self.mySuview.transform = transform;
//COMMIT ANIMATIONS
[UIView commitAnimations];
}
The first time you click, the view spins alright, but when you click again NOTHING happens. No errors, no changes on the view.
What am I missing?
Thanks
Gonso