Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No back button on segue in Swift 2

I just ported my project over to Swift 2, and everything is working great - except that even the most simple segues have no back button. Here is the prepare for segue function that I am using:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if segue.identifier == "showExercise" {
        if let nav = segue.destinationViewController as? UINavigationController {
            if let exercisesController = nav.topViewController as? ExercisesController {
                let cell = sender as! WorkoutCell
                if let workout = cell.name!.text {
                    exercisesController.exercises = Workouts[workout]!
                    exercisesController.navigationItem.title = workout
                }
            }
        }
    }
}

Before, the back button to the parent segue used to automatically populate. Now, all I get is the title in the child navigation vc

like image 993
cadlac Avatar asked Jun 21 '15 04:06

cadlac


1 Answers

Are you using show or show detail segue? It seems like you are using a modal segue. Destination view controller for show or show segue is usually the second view controller itself, and not embedded in another UINavigationController.

If your destination view controller for the show segue is really a UINavigationController, the new navigation controller's navigation bar settings may override the old one (the navigation controller of the source view controller). Try not embedding your destination view controller in another UINavigationController.

like image 172
chrisamanse Avatar answered Sep 19 '22 16:09

chrisamanse