To Use Unwind Segues in iOS.
1- Create three controller using storyBoard
2- Push from FirstViewControleller to SecondViewController
3- Push From SecondViewController to Third
Write a function in FirstViewController like this
-(IBAction)prepareForUnwind:(UIStoryboardSegue *)segue {
if ([segue.identifier isEqualToString:@"ThirdViewID"]) {
ThirdViewController *threeVC = (ThirdViewController *)segue.sourceViewController;
NSLog(@"color are %@", threeVC.mySelectedColor);
}}
4 - Create two button with title "Red" & "Blue"
5-Drag Home button on thirdViewcontroller to the Exit outlet to create our Unwind Segue
6- Write ibaction for two button "Red" & Blue like this
- (IBAction)redAction:(id)sender {
self.mySelectedColor = @"Red";
[self performSegueWithIdentifier:@"ThirdViewID" sender:self];
}
- (IBAction)blueAction:(id)sender {
self.mySelectedColor = @"Blue";
[self performSegueWithIdentifier:@"ThirdViewID" sender:self];
}
0 Comment(s)