I had asked this question once before but has had 0 attention and the person helping me has not responded in weeks, so please forgive me but I still do need help.
Im working with CGAffineTransformMakeRotation to flip a UILabel 180 degrees, I want the rotation based on UIOrientationPortrait and UIOrientationPortraitUpsideDown. I get 1/2 the result: when users flip to upside down (from portrait) the label transforms 180 and turns upside down as well (still facing the home button [Important])
BUT
when I rotate it back to Portrait the label stays in the flipped rotation state and does not stay with the home button. Thats what I need help with....
Here is the code i have:
#define degreesToRadian(x) (M_PI * (x) / 180.0)
...
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
}
You are rotating it upside down no matter what the orientation is. If you want it to rotate differently depending on the orientation, you have to do something like this:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
switch(toInterfaceOrientation){
case UIInterfaceOrientationPortrait:
TranslateLabel.transform = CGAffineTransformIdentity;
break;
case UIInterfaceOrientationPortraitUpsideDown:
TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
break;
}
}
That way, it will rotate the label upside down when the device is upside down and it will return it back to normal when the device is on portrait orientation.