3
votes

I am trying to have nested view controllers for detail view controller of a UISplitViewController. To make things simple, I leave the master view as it is; the detail view has a button inside it, 'Go further', which segues to the second view controller. In a compact device, iPhone, everything works fine, user taps on 'Go further' and it navigates to second view controller and back button appears on top left and user can go back to the first view.

But in landscape mode for iPad, when user clicks 'Go further' button and navigates to the second view controller there is no back button up there.

It's my setup: enter image description here

And the whole project is available at https://github.com/maysamsh/SplitViewWithNestedDetailViews

1

1 Answers

5
votes
  1. The root of the problem is the Navigation Controller between First One and Second One. It's not necessary, so go ahead and delete it.
  2. Create a Push segue directly from the Go Further button to the Second One's view. enter image description here
  3. Change the prepareForSegue in FirstViewController to this:

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let controller = segue.destination
        controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
        controller.navigationItem.leftItemsSupplementBackButton = true
        print("prepare")
    }