修复横向 iPad 应用程序中的键盘方向(颠倒键盘)
我正在将横向 (UIInterfaceOrientationLandscapeRight) iPhone 应用程序转换为通用应用程序。到目前为止,我的方向工作正常:iPad 版本将以正确的启动图形启动,并以正确的方向(LandscapeLeft 或 LandscapeRight)开始,具体取决于用户如何握住它。
但是:当我在 iPad 处于 LandscapeLeft 状态时触发键盘时,键盘会上下颠倒:
我还无法发布图像,因此您可以在此处看到错误: http://blog.durdle.com/images/ipad_keyboard.png
这是一个 UIAlertView添加了 UITextField。我猜此时键盘处于 LandscapeRight 方向。
如果我将设备旋转到 LandscapeRight,游戏视图会旋转以匹配键盘,然后如果我将设备旋转回 LandscapeLeft,整个界面 - 游戏和键盘会一起旋转以正确显示。
那么:如何确保它以正确的方向显示?
I'm converting a landscape (UIInterfaceOrientationLandscapeRight) iPhone app to be a universal 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哎呀。男孩,我觉得自己很愚蠢。
我将此代码留在了打开 UIAlertView 的方法中:
当我需要在 OS 2.2.1 中强制键盘方向时,这是原始 iPhone 应用程序的保留。现在完全没有必要了!删除它就解决了问题。
Oops. Boy do I feel foolish.
I'd left this code in the method that opens my UIAlertView:
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.