在Swift 2中没有关于segue的后退按钮

cad*_*lac 7 ios segue swift ios9 swift2

我把我的项目移植到Swift 2上,一切都很好 - 除了最简单的segue没有后退按钮.这是我正在使用的segue函数的准备:

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
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

之前,父segue的后退按钮用于自动填充.现在,我得到的只是儿童导航vc中的标题

chr*_*nse 10

你在使用show或show detail segue吗?看起来你正在使用模态segue.show或show segue的目标视图控制器通常是第二个视图控制器本身,而不是嵌入另一个视图控制器UINavigationController.

如果show segue的目标视图控制器确实是a UINavigationController,则新导航控制器的导航栏设置可能会覆盖旧的导航栏设置(源视图控制器的导航控制器).尝试在其他未嵌入你的目标视图控制器UINavigationController.