Fix keyboard orientation in landscape iPad app (upside down keyboard)
I'm converting a landscape (UIInterfaceOrientationLandscapeRight) iPhone app to be a un开发者_开发技巧iversal app. So far I've got the orientation working properly: the iPad version will launch with the right splash graphic and start in the right orientation (LandscapeLeft or LandscapeRight) depending on how the user is holding it.
But: when I trigger the keyboard while the iPad is in LandscapeLeft, the keyboard appears upside down:
I can't post images yet so you can see the error here: http://blog.durdle.com/images/ipad_keyboard.png
That's a UIAlertView with a UITextField added to it. I guess the keyboard at this point is in the LandscapeRight orientation.
If I rotate the device to LandscapeRight, the game view rotates to match the keyboard, then if I rotate the device back to LandscapeLeft the entire interface - game AND keyboard rotate together to appear correctly.
So: how do I ensure it appears in the correct orientation?
Oops. Boy do I feel foolish.
I'd left this code in the method that opens my UIAlertView:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
Which was a holdover from the original iPhone app when I needed to force the keyboard orientation in OS 2.2.1. It's now entirely unnecessary! Removing it has fixed the problem.
精彩评论