Hacker News new | ask | show | jobs
by DrJokepu 5167 days ago
I think one of the hardest part of login views and other forms in iOS is dealing with the keyboard. You don't want the keyboard to hide stuff but you also don't want emptiness where they keyboard would be when the keyboard is not visible. Also they size of the keyboard is not fixed. In this particular case, the input accessory view of some keyboards, such as the Japanese keyboard would overlap with the button. In the case of a login view, you want to trigger a login event when the user touches the Done button as opposed to making the UITextField resign its first responder status, which means that on the iPhone the user won't be able to dismiss the keyboard, so all the other login options as well as the sign up button will be hidden forever if the user changes his mind. Ultimately, you want to have the whole thing in a UIScrollView (or a UITableView) to avoid such problems. And leave more space for the keyboard.
2 comments

  > Ultimately, you want to have the whole thing in a
  > UIScrollView (or a UITableView) to avoid such problems.
Or you can just change the class of background view to UIControl and wire it so it calls resignFirsResponder on inputs if touched.
Yes, that would work as well, but if you do that, you have to make sure that you leave a wide enough margin (at least 44 points wide) on each side of the controls to allow for touching the background.
You can scroll the entire screen up by exactly the amount needed to prevent the keyboard from obscuring the field. It doesn't even need to be on a scrollview.

You'd think the framework would do that (or at least offer that), but nope.

This is also a good approach, but if you do that, you have to remember two things. First, you can only reliably measure the height of the keyboard at runtime, and the keyboard size could change even after it was displayed (if the user touches the globe button to change the language of the keyboard). Second, if your app supports the iPad as well, you have to remember that on the iPad the keyboard is detachable since iOS 5 so make sure you won't have anything ugly (like a big empty black rectangle) where the keyboard would normally be.