解除2个视图控制器的麻烦

我在视图控制器上有一个button(后退button)。 迄今为止简单。 我有两个视图控制器,每个表上有一个表。 如果用户从任一表中select一行,则它将打开后退button进入视图控制器。 后退button需要返回到用户select行时所在的原始视图控制器。

我正在考虑放松这个很好,但我不能将两个赛段添加到一个button。 一个用于返回一个表视图,另一个表视图的返回取决于他们用于访问视图控制器的哪个表视图。

有任何想法吗 ?

福尔克解释说,

 -(IBAction)devDismiss { NSLog(@" ------- dev dismiss ....."); // for a custom segue unwind, you must do this... [self performSegueWithIdentifier:@"specialWord" sender:self]; // "specialWord" is the identifier set on storyboard for the // custom unwind segue /* for a "default" unwind segue, do this... [self dismissViewControllerAnimated:YES completion:nil]; Note, if you used a push segue, you should use [self.navigationController popViewControllerAnimated:YES] If you used a modal segue, you should use [self dismissViewControllerAnimated:YES completion:nil] " */ } 

请注意,你也必须在你的segueForUnwindingToViewController:override中使用“specialWord”,它将在DESTINATION(也就是ORIGINAL)视图控制器中,也就是下面的那个。

 -(UIStoryboardSegue *)segueForUnwindingToViewController: (UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier { NSLog(@"we're in _your class name_, segueForUnwindingToViewController %@", identifier); // for some unwinds, we have a custom unwind we want to use. // so, check the identifier: if ([identifier isEqualToString:@"specialWord"]) { YourCustomUnwindSegue *sg = [[YourCustomUnwindSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController]; return sg; } // don't forget the break-away "return" inside any macthes. // NSLog(@"note, if this message appears, it's likely you have a typo // somewhere for 'specialWord' - unless you genuinely have a situation // where it will also fall through to the 'default' unwind segue :O "); // BE SURE TO return the default unwind segue otherwise return [super segueForUnwindingToViewController:toViewController fromViewController:fromViewController identifier:identifier]; }