I send the user over to a page on a button click. This page is a UITableViewController.
Now if the user taps on a cell, I would like to push him ba
Swift 3
I might be late in the answer but for swift 3 you can do it this way:
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "< Back", style: .plain, target: self, action: #selector(backAction))
// Do any additional setup if required.
}
func backAction(){
//print("Back Button Clicked")
dismiss(animated: true, completion: nil)
}
Swift 4
there's two ways to return/back to the previous ViewController :
self.navigationController?.pushViewController(yourViewController, animated: true)
in this case you need to use self.navigationController?.popViewController(animated: true)
self.present(yourViewController, animated: true, completion: nil)
in this case you need to use self.dismiss(animated: true, completion: nil)
In the first case , be sure that you embedded your ViewController to a navigationController in your storyboard
For questions regarding how to embed your viewController to a navigationController in the storyboard: