0

Im looking for the code necessary to fire my UILabel.transform only on a certain orientation, upside down (with good reason) My universal app only supports portrait orientation, both regular and upside down. So far so good! I have the code needed to transform the label 180 degrees (upside down/reverse text)

.H
#define degreesToRadian(x) (M_PI * (x) / 180.0)
IBOutlet UILabel *Label;

.M
Label.transform = CGAffineTransformMakeRotation(degreesToRadian(180));

The code I would like is:

When in regular portrait (home button on the bottom) the label is normal. When in upside down portrait (home button on top, camera on bottom) the label is transformed.

Thanks in advance!

P.S. Your help on this is going to a notable good cause that I would love to share when it's complete (few days away)

1 Answers1

0

You need to override willAnimateRotationToInterfaceOrientation:duration: in your UIViewController subclass. In that method, you can check the new interface orientation and set the label's transform appropriately.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • Awesome, I did not know what to override and now that I know what its called I was able to find more information from there. I think I have the necessary code, but no device to test on currently. Can you please check this for me? I will post in a 2nd comment. –  Jan 07 '12 at 06:23
  • - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterf‌​aceOrientation duration:(NSTimeInterval)duration { if (UIInterfaceOrientationIsPortrait(UIInterfaceOrientationPortraitUpsideDown)) { TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180)); } } –  Jan 07 '12 at 06:25
  • Just test it in the simulator. You can rotate the simulator by choosing Rotate Left or Rotate Right from the Hardware menu in the menu bar. – rob mayoff Jan 07 '12 at 06:27
  • Edit your question and post your new code. Or make a new question. – rob mayoff Jan 07 '12 at 08:01
  • Okay so just moved transform into that method from viewDidLoad and its works as intended, it only flips the label when in upside down mode, however when i switch back to portrait it does not transform again (in simulator) I'm curious if i need to add another statement to handle this or if this is just a simulator bug? –  Jan 07 '12 at 08:02
  • I can't answer your question if you don't show me your code. Edit your question to include your code, or open a new question and include your code. Either way, show me your code. (Hint: show me your code.) – rob mayoff Jan 07 '12 at 09:02
  • Hey Rob, Sorry I have been very busy but am now getting back around to this, could you confirm you are available? I would like to post some code and get it resolved correctly. –  Jan 22 '12 at 19:07