No back button on segue in Swift 2

微笑、不失礼 提交于 2019-12-07 00:35:55

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/30961247/no-back-button-on-segue-in-swift-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!