Reputation: 44312
My initial scene has a navigation controller embedded. This scene links to a UITableViewController scene. The tableview scene doesn't know anything about the navigation controller.
In the tableview scene, I've added a navigation bar and left button called back. How do I get back to the previous scene?
I have the following action associated with the back button:
self.navigationController?.popViewControllerAnimated(true)
But it doesn't do anything because self.navigationController
is nil.
Upvotes: 1
Views: 56
Reputation: 13893
If your navigationController
is nil
, then your scene must have been display
ed modally, not push
ed onto a nav controller. Instead of pop
ping it, you have to call dismissViewController
on it.
A better approach than using a left button item to navigate is to use the nav bar's built-in functionality by setting a custom backIndicatorImage
and mask.
Upvotes: 2