在Swift 2中没有关于segue的后退按钮 [英] No back button on segue in Swift 2
问题描述
我刚将我的项目移植到Swift 2,一切都运行良好 - 除了最简单的segues没有后退按钮。以下是我正在使用的segue函数的准备:
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
}
}
}
}
}
之前,父segue的后退按钮用于自动填充。现在,我得到的只是儿童导航中的标题vc
Before, the back button to the parent segue used to automatically populate. Now, all I get is the title in the child navigation vc
推荐答案
你使用show或show detail segue吗?看起来你正在使用模态segue。 show或show segue的目标视图控制器通常是第二个视图控制器本身,而不是嵌入另一个 UINavigationController
。
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
.
如果show segue的目标视图控制器实际上是 UINavigationController
,则新导航控制器的导航栏设置可能会覆盖旧的导航栏设置(源视图控制器的导航控制器) 。尽量不要将目标视图控制器嵌入另一个 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
.
这篇关于在Swift 2中没有关于segue的后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!