6.1. Adding a Navigation Controller to a Storyboard
Problem
You want to be able to manage multiple view controllers inside a storyboard-based application.
Solution
Set a navigation controller as the initial view controller of your storyboard file.
Discussion
When you create a new universal iOS app using the Single View Application template in Xcode, you will get two storyboard files: Main_iPhone.storyboard and Main_iPad.storyboard. If you view them in Interface Builder, you’ll notice that they contain a view controller as their root controller. Figure 6-1 shows the contents of a simple out-of-the-box iPhone storyboard file.
In order to change the root view controller of your storyboard file into a navigation controller, all you have to do is the following:
Select your view controller on the canvas of the storyboard.
From the Edit menu, choose Embed In and then Navigation Controller (see Figure 6-2).
Once you are done, you will notice that the root view controller of your storyboard is now a navigation controller, as shown in Figure 6-3.

Figure 6-1. A view controller as the root of a storyboard file

Figure 6-2. Embedding your view controller in a navigation controller

Figure 6-3. A navigation controller ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access