1

When a have an ViewController and insert Navigation Item create automatically a Back button. In my tableView i use an didSelectRowAtIndexPath to case into the ViewS and this views are using the same navigation Item, but dont create the back button.

Gabriel Rodrigues
  • 510
  • 1
  • 8
  • 29

3 Answers3

1

The back buttons are created automatically on a push/segue. If you want to create this functionality yourself you would have to set the leftBarButtonItem property of the UINavigationItem and implement a method to call:

func backBTPressed() {
     self.navigationController.popViewControllerAnimated(yes)
}

See:

Add a back arrow to leftBarButtonItem?

creating back arrow shaped leftBarButtonItem on UINavigationController

Community
  • 1
  • 1
keji
  • 5,947
  • 3
  • 31
  • 47
1

You can also do a push in your previous view controller in the method tableView:didSelectedRowAtIndexPath:

 func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {

  var newViewController = ..
  self.navigationController!.pushViewController(newViewController, animated: true)
 }

And it is done. The back button is already there.

0

You can try unwind segue. Check the following link.

Tutorial

Karlos
  • 1,653
  • 18
  • 36