How to Use Inspector and Quick Help Pane for iOS App Development
How to Add a Background Image to Your iOS App
How to Customize Xcode for Your iPad 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 Use a Navigation Controller in the Master View for Your iOS App
How to Add the Events Controller to Your iOS App
How to Add and Set Up the EventPageController in the MainStoryboard in Your iOS App
How to Create an Xcode Project for an iPad App