14

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.

enter image description here

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.

Imran
  • 1,488
  • 1
  • 15
  • 36
  • 2
    this kind of issues usually appear when the _view-layer_ is not built up correctly or the _orientation support_ in the app does not meet the standards. I would recommend you to revise those parts with paying double attention again before shouting any _bug_. – holex Oct 03 '14 at 11:36
  • 1
    Possibly but the same issue appeared during beta and was pointed out on the apple developer forum. However, there are no further comments on the issue there so if it is user error then its a pretty common issue and something that has changed between iOS7 and iOS8. – Imran Oct 03 '14 at 11:54
  • Yes, i'm saying there probably is an issue in the setup of the keyboard / orientation but i can't for the life of me figure out what it is. I didn't see the issue under iOS 7 or 6 with the exact same application so if something is set up incorrectly it is only surfacing now. Perhaps someone else has run in to the same problem? It doesn't hurt to ask. – Imran Oct 03 '14 at 12:23
  • I understand your motivation, but it would be more helpful if you could extend your post with telling the community how this _'bug'_ can be replicated. – holex Oct 03 '14 at 12:46
  • Well if I knew that I could probably fix it! So far I have a vanilla test project which does not replicate the issue. I am trying to use the same project settings but no luck reproducing it at the moment. – Imran Oct 03 '14 at 12:51
  • I have seen this issue often in alerts. Do you have the keyboard in an alert or actionsheet? If so, put it in a UIAlertController – brendan Oct 08 '14 at 16:02
  • no just on normal view controllers. – Imran Oct 08 '14 at 16:45
  • 1
    Did you ever solve this? I'm seeing the same thing on an app that worked without this problem in iOS < 8. – Rich Everhart Nov 26 '14 at 23:33
  • I documented my solution in the question above but I didn't get to the bottom of why it was an issue. – Imran Nov 27 '14 at 10:37
  • I have similar code in the app I'm working on, but removing it also removes the tab bar, which is managed by a UITabBarController instance, so I'm not sure I can go that route. – Rich Everhart Dec 01 '14 at 22:39
  • This is what worked for me: http://stackoverflow.com/questions/25754942/how-to-enable-native-resolution-for-apps-on-iphone-6-and-6-plus. Even though this issue with the keyboard seems unrelated to having a launch image, providing one (a xib in my case) fixed the problem. – Rich Everhart Jan 06 '15 at 01:22

5 Answers5

3

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"];
Emmo213
  • 87
  • 5
  • I edited my answer above. You might want to try it and see if it helps. – Emmo213 Oct 01 '14 at 15:09
  • Nope didn't help. This looks like it just sets the allowed orientation the same as I have already done in the project settings. The problem is the keyboard ignores it. – Imran Oct 01 '14 at 17:20
  • 1
    I am having the same problem... any solutions yet?? – Steffan Oct 03 '14 at 02:40
  • Not yet, its quite a problem! Maybe vote up the question so more people see it as it seems to have been lost in the stack overflow ether. – Imran Oct 03 '14 at 11:19
  • I tried this and it kind of helps, but this just happens to me with an iPhone 6 Plus, the iPhone 5 did not show this behaviour. I posted a complete solution that it works for me... – Carles Estevadeordal Oct 11 '14 at 18:37
  • Well I tried this solution further and it is definitely not working. – Carles Estevadeordal Oct 11 '14 at 19:19
  • this is TRYING to force the orientation of the device -- won't work and 'evil'(tm) – Daij-Djan Oct 11 '14 at 19:58
  • Actually I do want to force the orientation of the device. I want it to be in portrait when I tell it and in landscape when I tell it. That is a requirement from our business partners and iOS8 is making that very difficult. – Emmo213 Oct 30 '14 at 17:37
1

I was facing the same problem mentioned by Carles Estevadeordal on iOS 8 device for the application developed for iOS 7.

After little investigation I found that application was calling following method of UIViewController,

"+ (void)attemptRotationToDeviceOrientation"

Description of this method given in UI framework is, “if the current interface orientation does not match the current device orientation, a rotation may occur”

Simply commenting this method call,the issue got resolved.

Avadhut
  • 11
  • 2
  • This was my case as well. I was using this method in my AppDelegate to enforce correct UIAlert orientation in iOS7. Turns out that was causing the problem with keyboard in iOS8 scaled mode. – Stanislav Dvoychenko Dec 27 '14 at 00:24
1

It is is not a bug of iOS8 or iPhone 6. It is problem of the correct migration of old projects to xCode6.

You simply need to add Launch screen interface file base name key to Info.plist file.

Detailed explanation of this case you can find here.

Community
  • 1
  • 1
Daniel Lyon
  • 1,499
  • 10
  • 15
0

My problem similar to the question, I tied Emmo213 solution but the error seems to go randomly off and on, so this does not work, the problem in my case seems only to affect the iPhone 6 Plus. I decided to let the response since it may help somebody, if I find one i will edit the response.

iPhone 6 Plus Keyboard disappearing and wrongly placed randomly


Edit: Found a solution, the problem definitely does not happen when the App is not working in scaled mode: How do I create launch images for iPhone 6 / 6 Plus Landscape Only Apps?


Edit: This is definitely not a solution since the problem goes on and off randomly.

I tried Emmo213 solution to the problem and it kind of fixed the problem for me, yet afterwards I deleted this part of code and could not reproduce the problem again...

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                            duration:(NSTimeInterval)duration {
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
        UIDeviceOrientation deviceOrientation;
        switch (toInterfaceOrientation) {
            case UIInterfaceOrientationLandscapeLeft:
                deviceOrientation=UIDeviceOrientationLandscapeRight;
                break;
            case UIInterfaceOrientationLandscapeRight:
                deviceOrientation=UIDeviceOrientationLandscapeLeft;
                break;
            case UIInterfaceOrientationPortrait:
                deviceOrientation=UIDeviceOrientationPortrait;
                break;
            case UIInterfaceOrientationPortraitUpsideDown:
                deviceOrientation=UIDeviceOrientationPortraitUpsideDown;
                break;
            default: deviceOrientation=UIDeviceOrientationUnknown;
                break;
        }
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:deviceOrientation] forKey:@"orientation"];
    }
}

I hope it may help somebody, but since it looks like a rare buggy behaviour difficult to reproduce I cannot assure this is a valid solution...

Community
  • 1
  • 1
0

It is basically the Bug in Xcode 6, to avoid this you may build your project using Xcode 5 or Using Xcode 7. I tried on xcode5 and xcode7-beta and on both versions the keyboard problem was not there. But when i build using xcode 6 then the problem appears , so try to build your project using Xcode 5 or Xcode7 (Soon stable version of Xcode7 will available.). Hope this will help.

Abuzar Amin
  • 1,981
  • 1
  • 19
  • 33