gavsta707 gavsta707 - 3 months ago 4
iOS Question

Issue with popping to a previous view (navigation controller)

The Issue

So, I found (you are familiar with this if you saw my previous question) that i needed to implement a navigation controller stack. So, i replaced a few of my segues to push segues, in order to push these views onto my navigation stack. Unfortunately, in the third view seen in the picture below, i am trying to use the popping feature to return to the previous view. So far, i have used the recommended code to accomplish such, and to no avail. I hope you guys can spot something i can't!

The Code

Below is the action function for a back button on the third view (unfortunately something is messed up in the screen shot, but rest assured there is a white arrow back button).

@IBAction func back(_ sender: AnyObject) {
if let navController = self.navigationController {
navController.popViewController(animated: true)


First, it looks like your NavigationController is not your Initial View Controller. The arrow is pointing at the one in the middle, not the one on the left as I would expect.

As to your follow up question, removing the navigation bar at the top is easy enough.

Just add this to your UIViewControllers:

override func viewWillAppear(animated: Bool) {
    self.navigationController?.navigationBar.hidden = true

As far as I know you have to remove it for each UIViewController in your stack.

One other thing. Your code for "back" can be simplified:

@IBAction func back(sender: AnyObject) {