iOS 8横向:键盘无法正确显示 [英] iOS 8 Landscape orientation: Keyboard does not display correctly

查看:62
本文介绍了iOS 8横向:键盘无法正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个为iOS8编译的应用程序.该应用程序设置为仅在项目设置中允许纵向方向.根据设计,应用程序的视图不会旋转到横向.在iOS7中,当您旋转设备使其横向移动时,键盘不会旋转.这是我想要的行为.

I have an application compiled for iOS8. The app is set to allow portrait orientation only in the project settings. The views of the application do not rotate to landscape by design. In iOS7 when you rotate the device to landscape the keyboard is not rotated. This is the behaviour I desire.

但是,在iOS8中,当您将设备旋转至横向时,键盘会错误地切换为横向.

However, in iOS8 when you rotate the device to landscape the keyboard will incorrectly switch to landscape orientation.

我已在实际的iPhone 6 Plus上对此进行了测试,以确认问题.还通过模拟器在iPhone 5上对其进行了测试.知道如何解决此问题吗?

I have tested this on a physical iPhone 6 Plus to confirm the issue. Also tested it on iPhone 5 via simulator. Any idea how to fix this issue?

潜在解决方案

我不记得是什么原因,但是我有一些启动应用程序时会执行的自举代码:

I don't remember exactly why I was doing it but I have some bootstrapping code that executes when the app starts:

    d.window.rootViewController = tabBarController;

其中tabBarController是应用程序的顶级标签栏控制器.删除此引导代码即可解决此问题.

Where tabBarController is the top level tab bar controller for the app. Removing this bootstrapping code fixes the issue.

建议的调试

虽然在以前的iOS版本中没有出现,但iOS8的行为似乎有所不同.我建议检查您拥有的所有引导代码.您可能必须尝试一个示例项目并添加一些位,直到找到罪魁祸首,因为在我的案例中很难找到答案.下面提供的两个答案是固定症状而不是原因的,因此我没有将其标记为正确.

Whilst this did not appear in previous versions of iOS it looks like iOS8 behaves a bit differently. I would recommend checking any bootstrapping code you have. You may have to try a sample project and add some bits until you find the culprit as it was quite hard to track down in my case. The two answers provided below are kind of fixing the symptoms not the cause so I have not marked them as correct.

推荐答案

我有一个类似的问题,发现在iOS8之前,键盘方向与状态栏的方向有关,但不幸的是,在iOS8中,键盘和状态栏的方向是分开的.尽管它无助于解决您的问题,但希望它能提供一些有关其原因的信息.

I have a similar problem and have found that pre iOS8 the keyboard orientation is tied to the orientation of the status bar but unfortunately in iOS8 the keyboard and status bar orientation are separate. While it doesn't help solve your problem hopefully this provides a little bit of information as to why it's happening.

尝试以下代码-它对我有用.根据允许的方向,您必须更改明显翻转设备的方式.

Try the following code - it worked for me. Based on which orientations are allowed you'll have to change which way you're flipping the device obviously.

// Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa).
// This is because rotating the device to the left requires rotating the content to the right.
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];

这篇关于iOS 8横向:键盘无法正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆