Hour 13: UINavigationController Changes

In Xcode 4.3 and later, Apple has changed what happens when you add a navigation controller to your project. Instead of giving you a blank UIViewController (labeled “Root View Controller”) to do with as you please, it links you to a table view controller.  The good news is that you can still easily remove this table view controller and connect to whatever type of scene you want.

For example, in the Hour 13 “LetsNavigate” project, after adding the navigation controller, your Storyboard will look like this:

To change back to a “normal” view controller (UIViewController) in place of the table view controller (UITableViewController), follow these steps:

  1. Select the “Table View Controller – Root View Controller” line in the Document Outline.
  2. Press Delete to remove the scene.
  3. Drag a new view controller (UIViewController) from the Object Library into the Interface Builder editor.  A new scene is created and your document should resemble this:
  4. Now, control-drag from the navigation controller to the new view controller.  When finished dragging, release your mouse button.
  5. You will be prompted for the type of connection to make.  Choose “Relationship – Root View Controller” as demonstrated:
  6. You’ve now coupled the navigation controller with a new view controller.  Aside from not reading “Root View Controller” at the top, this is identical to how the template was previously constructed. (Feel free to double-click the bar at the top of the new view controller and add text with the root view controller label if you wish.)


Posted in iOS 5 Errata, Notes