Friday, 27 January 2012

iPhone keyboard - hide when done

Ever got stuck in a form using an iPhone app? You've edited a text field but you're left with the keyboard hiding the form submit button. I have, and its bloody annoying (most recently in the otherwise excellent pixlr-o-matic app), and it almost feels like some fundamental Apple design flaw. But you should blame the developer, because what he/she forgot to do was tie an action to the text field's 'Did End On Exit' event.

The keyboard hiding method declared in the action just needs to do one thing - resign the text field as first responder, like so:
[yourTextField resignFirstResponder];
And, to make things even better for your user, change the return key to 'Done' in your Attributes Inspector.

And even better still, create a big invisible custom button behind all your other controls and attach it to your keyboard hide method too. This will comply with the common convention that a touch outside of any controls kills the keyboard.

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!