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.
However, in iOS8 when you rotate the device to landscape the keyboard will incorrectly switch to landscape orientation.
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?
POTENTIAL FIX
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;
Where tabBarController is the top level tab bar controller for the app. Removing this bootstrapping code fixes the issue.
SUGGESTED DEBUGGING
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.
Swipe up from the bottom edge of your screen to open Contol Center. Tap the Portrait Orientation Lock button to make sure that it's off.
To reset the iOS keyboard, perform these steps: Open the Settings app. Select General | Reset. Select Reset Keyboard Dictionary and then type in your iOS passcode to continue with the reset (Figure C).
On an iPhone 8 or earlier, swipe up from the bottom of the screen to access it. iPhone X and newer users should instead swipe down from the top-right corner of the screen. Here, tap on the rotation lock icon (which looks like a lock with a circular arrow around it) to turn it on/off.
Assign an alternative layout to a keyboardGo to Settings > General > Keyboard > Keyboards. Tap a language at the top of the screen, then select an alternative layout from the list.
Another common reason for this iPhone landscape keyboard text problem is orientation lock. Check and see if your iPhone’s portrait orientation lock is in the top screen status bar. If so, turn it off by swiping up from screen bottom to open the Control Center, then tap to unlock. to learn more about control center, check out this article.
IOS 14.2. No Landscape Mode I have three iOS devices - an iPad and two iPhones. All running iOS 14.2. Landscape mode does not run on any of them. Portrait orientation lock is off. There are no widgets on the Home Screen. I’ve restarted all devices more than once
Good news, though, How-To Geek points out that when you tap the keyboard button, iOS remembers your preference. When you type out a message in Messages and flip your phone horizontally, just tap the keyboard button in the bottom right corner. That pulls up the landscape keyboard.
By default, iPhone display automatically adjusts depending on the orientation of your device. When you have your iPhone positioned vertically, the screen orients into portrait mode. If you are holding it horizontally, your screen will switch to the landscape mode. However, you may find that you cannot keep your iPhone in the landscape mode.
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.
Edit: 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"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With