views:

58

answers:

2

Hey everyone, I've been working on my first iPad based project which has proven a massive learning curve but I'm nearly there. I have a small issue left however.

I've got my iPad to work in all orientations as dictated by Apple however they keyboard always comes on from the Portrait position unless the user rotates the device first. Does anyone have any suggestions where this is coming from? Just can't seem to figure out the reasoning for it. Any thoughts much appreciated, I'm sure this is glaringly simple but I'm just pulling my hair out here.

+1  A: 

The keyboard displays based on the device's true orientation regardless of the layout any views. If the device is in portrait, the keyboard displays in portrait and it will not change until the device is physically rotated to landscape.

TechZen
Or the code manually sets the device orientation...
jrtc27
This is much what I figured might be the case. Is there a simple way of getting the device to see it's true orientation on startup? A prime example is that my app starts in Landscape left (just because I've how I'm holding it, not progmatic) but still detects as in portrait.
David26th
You need to set the `UIInterfaceOrientation` key in the `info.plist` to `UIInterfaceOrientationLandscapeRight/Left` so that the app knows it should startup in landscape. Otherwise, it will default to portrait and then rotate.
TechZen
But that's just it, I don't want to set up a specific startup orientation, that goes against iPad User Interface Guidelines and would lead to the same problem just from a different angle. What the app needs to do is to detect what orientation is being started up in and account for it.
David26th
Orientation is normally detected by view controllers so you can't get an orientation shift before the first view controller loads. The only way around this is to use `UIDevice` to detect the orientation in the app delegate and then call a different initial view controller based on the orientation. However, I'm not sure that this is your problem. If the keyboard displays in portrait mode, then the device thinks it is in portrait orientation so the above advice will not help. You need to figure out why either you or the device is confused about the orientation.
TechZen
It needn't necessarily be before the view controller loads as the keyboard isn't called until the user interacts with the textfield so I could probably detect during the viewdidload and work from there.
David26th
If you have the keyboard coming in from the portrait side when the device is already in landscape, then you have something wrong. The keyboard should automatically track the orientation. `viewDidLoad` is a bad place to put orientation checking because it is only called when the view is loaded from nib.
TechZen
A: 

Hi, I have the same problem. My application has a login interface which has two UITextField.

When I start my application in landscape mode, When I tap the TextField, the keyboard will appear in the direction of the home button. For example, if the home button is on the Left, the keyboard will shown from the Left. I need it shown from the bottom of the screen.

Zhe Du