Back button in the Detail view

2.2k views Asked by At

I'm struggling with "Master-Detail" concept and almost everything works as expected except one little(but important) nuance. What should I change on the storyboard to have Back button on Detail view(the right corner at the bottom on the screenshot)?

Thanks in advance. Storyboard

2

There are 2 answers

1
Sofeda On

So far don't get anything straight. If you want like just below screen then you have to hide your navigationItem backbutton in viewDidLoad like this

navigationItem.hidesBackButton = true

Then in storyboard you have add a toolbar and set it's item title 'Back'. You can also set image for it.

Then drag an action from this item and write this line inside that action

@IBAction func fbfdb(_ sender: Any) {
     self.navigationController?.popViewController(animated: true)
}   

You may get an warning but you will get your desire action

enter image description here

Storyboard

enter image description here

0
Dan On

This is an older question, but I just ran into the same thing. The issue is you do not need the navigation controller at the bottom right. Since that is a new navigation controller it will not have a back button, because it only contains one item in its stack.

Remove the bottom right navigation controller and just segue directly to the view controller and that will do it.

Additional tip... to remove the navigation controller and preserve the view, delete the link from the navigation controller to the view, and delete the segue links to the navigation controller. Then recreate the segues directly to your view controller.