views:

746

answers:

1

How do you get the keyboard (for editing a UITextField) to come up in the correct orientation if you are in Landscape mode?

I'm doing a game in openGL in landscape mode.

I add a UITextField when it's time for the user to enter their name for a high score. I can rotate the UITextField (with a CGAffineTransformMakeRotation thanks) but when the user taps in the TextField, the keyboard pops up in Portrait Mode. Not landscape.

I know the keyboard CAN come up in Landscape mode (it does in Safari) so how do I set it?

+1  A: 

Did you start the app in landscape mode, or are you using a transform? Sounds like you're using a transform - it might make your life easier if you just run everything in landscape, though I haven't played with OGL at all, so no idea if there are complications there.

You need to use UIApplication setStatusBarOrientation (yes, even if your status bar is hidden). That controls the orientation of the keyboard as well.

e.g. do this when you start your app (not right before you display the keyboard, you need to return control to the OS before it takes effect, IIRC).

[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeRight animated:NO]
Airsource Ltd