How to Add a New View Controller to Your iOS App
How to Customize Xcode for Your iPad App
How to Add a Background Image to Your iOS App

Add a Modal View to your iOS App

Modal views on the iPhone and iPad are great for those situations when you want the user (or the user wants) to do something outside the application flow. Rather than use a Navigation controller with a Back button, you display a Modal view with controls that allow the user to either select an action or cancel the procedure.

Much of the work in adding the Destination controller to your storyboard has to do with enabling the user to either select a destination in the Table view or to press Cancel to leave things as they are.

The usual way to manage Modal views is by creating an Objective-C protocol that's adopted by the controller presenting the Modal view. The Modal view, when the user has selected an action or Cancel, calls the presenting controller’s delegate method.

The requesting controller then dismisses the Modal controller. Using this approach means that, before it dismisses the Modal controller, the presenting controller can get any data it needs.

You start implementing the Modal view by declaring the protocol and a few other properties you’ll need, as well as the protocols the DestinationController needs to adopt.

The Objective-C language provides a way to formally declare a list of methods (including declared properties) as a protocol. If you’ve used framework-supplied protocols extensively, now you're defining your own protocol.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
How to Add a Toolbar to Your iOS App
How to Create an Outlet for the Map Controller in Your iOS App
How to Create an iOS App
How to Add a Button to Your iOS App
How to Customize Your iOS App Table View for the iPad
Advertisement

Inside Dummies.com