Reputation: 510
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.
Upvotes: 1
Views: 332
Reputation: 132
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.
Upvotes: 1
Reputation: 5990
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
Upvotes: 1