0

I am using a UISplitViewController to implement a Master/Detail flow app.

I am not using a Navigation Controller.

To go from the MasterViewController to the DetailViewController I am using: performSegueWithIdentifier("showDetail", sender: self)

What should I use to go back from the DetailViewController to the MasterViewController?

Daniele B
  • 19,801
  • 29
  • 115
  • 173
  • You can just add a segue attached to a button back to the master view controller (if necessary) but why are you avoiding the navigation controller? This situation is what it's built for. – Rob Norback Sep 25 '15 at 23:46
  • I only have two viewcontrollers (each viewcontroller has as a containerview and tabs inside), so I don't really need a navigation controller. Yes, I would like to use a simple back button, but what is the exact code to attach to the back button? – Daniele B Sep 25 '15 at 23:49

1 Answers1

3

I found a simple solution using the unwind action.

In the MasterControllerView I add the code:

@IBAction func backFromDetail(segue: UIStoryboardSegue) {
    print("back")
}

Using InterfaceBuilder, I create a custom Back button inside the DetailViewController, and I connect it to the Exit icon (as explained here) selecting "backFromDetail".

After this, everything works magically! You just click on the custom Back button to go back to master.

Community
  • 1
  • 1
Daniele B
  • 19,801
  • 29
  • 115
  • 173