sinusGob sinusGob - 4 days ago 5
Swift Question

Added navigation bar but there is no back button?

I created a table view and from there let say a user pressed a cell it will go to the detailItemView , but the only problem right now is that whenever a user is in detailItemView there is no back button even thought I already embed a navigation Controller

Here's the code that will perform a segue once a user pressed a cell:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

// Get the new view controller using [segue destinationViewController].
var nav = segue.destinationViewController as! UINavigationController
var detailScene = nav.topViewController as! DetailViewController

// Pass the selected object to the destination view controller.
if let indexPath = self.tableView.indexPathForSelectedRow() {
let row = Int(indexPath.row)
detailScene.currentObject = objects?[row] as? PFObject

The screenshot for the storyboard:

enter image description here

edited Screenshot

enter image description here

I tried to do the answer below but there is still no back button

Another screenshot, the detailView controller doesn't have a back button

enter image description here


Embed the TableViewController inside the NavigationController. Not the DetailViewController directly. Check out the screenshot.

Make sure, that the segue, connecting your TableViewController and your DetailViewController is of type Show (e.g. Push). You have to literally push a new View on top of the Navigationstack.

Check screenshot