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

3. Objective-C for iOS: Email needs vari... > Use message passing to tell our View...

Use message passing to tell our View Controller when the Done button is pressed

image with no caption

The UITextField can tell our ViewController when the Done button was pressed on the keyboard; we just need to tell it what message to send. We can do this with Interface Builder. You’ll need to declare an action in the .h file and implement it in the .m file:

  1. Add the IBAction to InstaEmailViewController.h.

    Just like we did with the “Send Email” button, go back into Xcode and add this:

    image with no caption
  2. Add the method implementation in InstaEmailViewController.m.

    Now that we have an action that will be called when the Done button is pressed, we just need to ask the textField to resign its first responder status and it will hide the keyboard.

    image with no caption

    Almost there, we just need to wire it up...


  

You are currently reading a PREVIEW of this book.

                                                                                        

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

  

Start a Free Trial