Xcode / Swift: How I implement a back button?

Laire picture Laire · Dec 21, 2015 · Viewed 38.3k times · Source

I just started with Xcode and Swift.

I try to build my first little App for iOS. But now I have the problem, that I don't know how to implement a the back button, so that i come back to the view before.

My Storyboard look like this:

Storyboard

When I open the A-Z view, I want to display the Back Arrow, which turn me back to the Item 2 view.

To open the A - Z view I connect the button "Medikamente A - Z" with the Navigation Controller.

Answer

little picture little · Dec 21, 2015

When using storyboards the back button is usually implemented with unwind segue.

I usually like to follow raywenderlich toturials on UI related topics, like this - http://www.raywenderlich.com/113394/storyboards-tutorial-in-ios-9-part-2

It include a detailed example of how to implement back button in storyboards. Quoting from it -

Storyboards provide the ability to ‘go back’ with something called an unwind segue, which you’ll implement next. There are three main steps: 1. Create an object for the user to select, usually a button. 2. Create an unwind method in the controller that you want to return to. 3. Hook up the method and the object in the storyboard.