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

5. Plists and Modal Views: Refining your... > Write the Save and Cancel actions

Write the Save and Cancel actions

When the user clicks either Save or Cancel, we need to exit the modal view by asking the View Controller that presented the view to dismiss it. However, to make things easier, we can send the modal view the dismiss message, and it will automatically forward the message to its parent View Controller. Since the AddDrinkViewController is the modal view and gets the button call back, we can just send ourselves the dismiss message and the controller stack will handle it correctly. We need to send ourselves the dismissModalViewControllerAnimated: message, like this:

[self dismissModalViewControllerAnimated:YES];
image with no caption

Now, to see if those buttons work...

Test Drive

The modal view can be dismissed now, and the keyboard works, too!


  

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


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