Reputation: 16074
I have a NavigationViewController which root is a regular UIViewController. I present a TableViewController programatically by:
self.performSegue(withIdentifier: "showTableViewVC", sender: nil)
This TableViewVC is showing the BACK button but it is not working at all.
The segue to this TableViewVC is a "show/push" segue.
How to navigate back to the UIViewController?
Upvotes: 0
Views: 4557
Reputation: 131
1. Add a UIBarbutton into navigation controller in showTableViewVC.
override func viewDidLoad() {
super.viewDidLoad()
let backBarButton = UIBarButtonItem.init(barButtonSystemItem: .add, target: self, action: #selector(backButtonTapped(sender:))) as UIBarButtonItem
self.navigationItem.setLeftBarButton(backBarButton, animated: true)
}
2. Implement back button Action.
func backButtonTapped(sender: UIBarButtonItem)
{
self.navigationController?.popViewController(animated: true)
}
Upvotes: 1