7

我刚刚将我的项目移植到 Swift 2,一切都运行良好 - 除了即使是最简单的 segues 也没有后退按钮。这是我正在使用的准备 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
                }
            }
        }
    }
}

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

4

1 回答 1

10

您使用的是 show 还是 show detail segue?好像您正在使用模态转场。show 或 show segue 的目标视图控制器通常是第二个视图控制器本身,而不是嵌入到另一个UINavigationController.

如果 show segue 的目标视图控制器确实是 a UINavigationController,则新导航控制器的导航栏设置可能会覆盖旧的(源视图控制器的导航控制器)。尝试不要将目标视图控制器嵌入到另一个UINavigationController.

于 2015-06-21T07:09:10.300 回答