Mike Mike - 26 days ago 7
Swift Question

How to navigate back from a navigation controller on the storyboard in xcode

I've got an initial view controller

InitialViewController
with a button "List" (and a few other random buttons).

Clicking on "List" segues to a
UITableViewController
that is embedded in a navigation controller. And that is all sweet.

But once the
UITableViewController
is loaded there is no "back" button to navigate back to Initi
a
lViewController.

I was just wondering what my options were. On the storyboard I've used a "Navigation Item" and "Button Bar" and i'll hook that up programmatically to navigate back.

I just wasn't sure if an unwind segue was an option or if anyone had better ideas.

Thanks.

Answer Source

The reason you don't see a back button when your UITableViewController is loaded is because it is the root view controller for the navigation controller that it is embedded in. As such, the NavigationController has no other view controller in the stack that it can go back to.

Instead of the TableViewController, embed your InitialViewController inside a NavigationController and that should add a navigation bar with Back button to your TableViewController.

If you don't want to show the Navigation Bar in your InitialViewController, you can hide it using the following steps:

  1. In your storyboard file, select the InitalViewController
  2. Open the Attributes inspector and set Top Bar to None

Hope this helps!