An unwind segue (sometimes called exit segue) can be used to navigate back through push, modal or popover segues (as if you popped the navigation item from the navigation bar, closed the popover or dismissed the modally presented view controller). On top of that you can actually unwind through not only one but a series of push/modal/popover segues, e.g. “go back” multiple steps in your navigation hierarchy with a single unwind action.
To enable the Unwind Segue you need to add some code first.
1
2
| @IBAction func unwindToVC(segue: UIStoryboardSegue) { } |
Unwind To View
Suppose you want to came back from second or third view to first view then you have to add the code in first view.
Then just connect any control(Which contains action) with the unwind segue.For check the particular view controller by unwind segue, use following code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| @IBAction func unwindToVC(segue:UIStoryboardSegue) { if (segue.sourceViewController .isKindOfClass(ViewController2)) { let alert = UIAlertView() alert.title = "UnwindSegue" alert.message = "Unwind from view 2" alert.addButtonWithTitle( "Ok" ) alert.show() } if (segue.sourceViewController .isKindOfClass(ViewController3)) { let alert = UIAlertView() alert.title = "UnwindSegue" alert.message = "Unwind from view 3" alert.addButtonWithTitle( "Ok" ) alert.show() } } |
No comments:
Post a Comment