Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 401
sinusGob Avatar asked May 19 '15 13:05

sinusGob


People also ask

How do I hide the back button on my navigation?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How do I push navigation controller?

To push UINavigationController , first create a subclass of UIViewController , which will be a wrapper-/container- class for your UINavigationController and its content. This is a much more comprehensive answer which addresses the need to support hierarchical navigation controllers without modal presentation.


2 Answers

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

like image 160
gutenmorgenuhu Avatar answered Oct 04 '22 04:10

gutenmorgenuhu


I've had the same issue just now, resolved by deleting segue, adding again and giving it an identifier straight away.

like image 24
OBEE Avatar answered Oct 04 '22 05:10

OBEE