0%

unwindSegue 实现界面跳转

传统的界面跳转方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//ThirdViewController
@IBAction func pop(_ sender: Any) {
navigationController?.popViewController(animated: true)
}

@IBAction func popToRoot(_ sender: Any) {
navigationController?.popToRootViewController(animated: true)
}
//ForthViewController
@IBAction func dismiss(_ sender: Any) {
dismiss(animated: true, completion: nil)
}



使用unwindSegue实现界面跳转:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//RedViewController
@IBAction func unwindToRed(sender: UIStoryboardSegue){
if sender.identifier == "FromGreenToRed" {
print("from green")
} else if sender.identifier == "FromYellowToRed" {
print("from yellow")
}
}
//GreenViewController
@IBAction func unwindToGreen(sender: UIStoryboardSegue){

}
//YellowViewController
@IBAction func unwindToYellow(sender: UIStoryboardSegue){

}