Understanding Views and Controllers
A key point to remember now is that view controller objects manage views. Views draw content, but user interaction and screen swaps are best handled by a view controller.
A single view controller is always loaded at startup, with a default screen of content defined in its nib file. Often, this view controller stays in memory and manages animated changes to further screens.
To add further screens, add further view controllers to your app. Each view controller is created with an associated nib file. To design the content for those screens, edit the corresponding nib file.
To switch between screens, add code to either the master view controller or the other view controllers, depending on the design of your app. The code loads a view controller and its associated nib file. The view content is added “free” when you load the controller.
You don’t load views directly from a nib file when you swap screens. You load a view controller object, and the view controller loads the view.
Screen swapping can feel clumsy and overly complex, so in iOS 5 Apple added a new feature called storyboards. A storyboard graphs the relationship between screens—or more accurately, it graphs various possible paths through a collection of view controllers. Animations are defined in the storyboard.
Figure 4.13 shows a simple example with two screens. We’ll work through a hands-on example of design with storyboards in Chapter 10.
4.13 A first look at ...