Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Working with Text > Recipe: Dismissing a UITextField Keyboard

Recipe: Dismissing a UITextField Keyboard

The most commonly asked question about the UITextField control is, “How do I dismiss the keyboard after the user is done typing?” There’s no built-in way to automatically detect that a user has finished typing and then respond. Yet, when users finish editing the contents of a UITextField, the keyboard really should go away. The iPad offers a keyboard-dismissal button but not the iPhone or iPod touch.

Fortunately, it takes little work to respond to the end of text field edits, regardless of platform. You do so by allowing users to tap Done and then resigning first responder status. Resigning first responder moves the keyboard out of sight, as Recipe 10-1 shows. Here are a few key points about implementing this approach:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint