Top Apps

« App Marketing | Main | Regular Expressions on iOS - NSRegularExpression »

Dismiss iPhone keyboard


Quick tip on how to dismiss the keyboard in iOS when a user touches anywhere on the screen outside of the UITextField or keyboard. Considering how much real estate the iOS keyboard can take up, it makes sense to have an easy and intuitive way for your users to dismiss the keyboard. Add the following code below to your .m file for your view controller.

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Response: best dating sites
    Dismiss iPhone keyboard - Blog - Remarkable Pixels

Reader Comments (7)

What code? Muppet!

January 24, 2011 | Unregistered CommenterSchmoo

You cant see the Gist?

January 24, 2011 | Registered CommenterAdam

Wow, the first solution I stumbled upon online after an hour of searching that "just worked!" Thank you so much! =D

December 9, 2011 | Unregistered CommenterMysticHLE

This looks like the kind of solution I've been looking for but it does not work.

I have a table view, three rows, one UITextField on each row. When I touch any of them the keyboard comes up but never goes back.

The instructions couldn't be any simpler. I've pasted the code on the .m file of my view controller. It's like I didn't put anything.

Any ideas why?

Thanks in advanced!

January 20, 2012 | Unregistered CommenterJuan

Works like a charm, thanks!

March 25, 2012 | Unregistered CommenterBathtub

Dude... thank you!

June 19, 2012 | Unregistered Commentermilesology

thanks, very useful code.

March 23, 2013 | Unregistered Commenteralex

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>