首页 > 代码库 > storyboard有多个Segue的传递

storyboard有多个Segue的传递

在项目中需要在一个页面向多个页面传不同的值。

在view2Controller和view3Controller中分别有相应的Str2和Str3

 1 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 2 { 3      4     NSString *view2 = @"goToView2"; 5     NSString *view3 = @"goToView3"; 6      7     if ([[segue identifier] isEqual:view2]) { //通过[segue identifier] 得到指向那个页面 8          9         UIViewController *send = segue.destinationViewController;10         11         if ([send respondsToSelector:@selector(setStr2:)]) {12             13             [send setValue:@"view2" forKey:@"Str2"];14             15         }16     }else if([[segue identifier] isEqual:view3]){17         18         UIViewController *send = segue.destinationViewController;19         20         if ([send respondsToSelector:@selector(setStr3:)]) {21             22             [send setValue:@"view3" forKey:@"Str3"];23             24         }25     }else{26         NSLog(@"nothing");27     }28 }

 

storyboard有多个Segue的传递