iphone: repeating a transformation
Posted
by gonso
on Stack Overflow
See other posts from Stack Overflow
or by gonso
Published on 2010-05-04T10:42:31Z
Indexed on
2010/05/04
10:48 UTC
Read the original article
Hit count: 251
iphone
|transformation
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
© Stack Overflow or respective owner