Chapter 12

Navigation Controllers

A lot of applications for Apple’s iOS devices display information on more than one view controller. On the iPad, for example, there is even a split view that displays two view controllers at once. The iPhone doesn’t have that luxury, so it must provide a way to navigate through a hierarchy of view controllers.

To be able to navigate from view controller to view controller, by either drilling down into a hierarchy of views controllers or returning back to the original view controller, there has to be a process to accomplish this.

Apple has provided developers with a navigation controller that manages the presentation of these view controllers in your application. The class provided is UINavigationController that controls a hierarchy of UIViewController classes.

The UIViewController class contains a view property that contains your custom view information for user interaction. This view is what users see on their device. This custom user interface is designed using the Xcode Interface Builder editor as shown in Figure 12-1.

In this lesson you learn how to add a navigation controller to your single view application. You learn how to navigate from one view controller to another, including returning back to the original root view controller. You also learn how to transfer data from one view controller to another.

note.eps
This lesson requires you to add the ...

Get iPhone and iPad App 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.