Today I’m going to present a workaround for a slightly obscure but still annoying problem on the iPhone. Let me begin by quoting myself:
If you create a view controller, put a UITextView inside a table cell in that controller’s view, make that UITextView the first responder, and then push the new controller onto a Navigation stack, the keyboard does not scroll in from the right; it pops into view immediately. That’s ugly …
It turns out that, with a little hack, you can make the keyboard slide in properly.
The trick is to place a “hidden”
UITextField (or similar widget; anything that brings up the KB when it’s the first responder) in your view controller’s NIB. For instance, you might place it behind a table view, as seen to the right.
If you make this “dummy” field the first responder in your view controller’s
viewDidLoad method (i.e. with
[dummyField becomeFirstResponder];), the keyboard will slide into view properly from the right. You may then assign focus to the proper control in the
It’s still not clear why this rigamarole is necessary, but at least it patches over the problem.