我有一个简单的UINavigationController,它通过自定义segue将UIViewController推送到堆栈.然后我在第一个UIViewController上实现了一个IBAction来执行一个展开动作,我实现了segueForUnwindingToViewController.不幸的是,没有调用segueForUnwindingToViewController(我确实确认在第一个VC上调用了canPerformUnwindSegue).
我没有看到任何这种行为的简单例子.有人可以帮忙吗?谢谢.
这是NavigationController的根视图控制器中的代码.
- (IBAction) unwindFromSegue:(UIStoryboardSegue *)segue { // unwinds back to here //[self performSegueWithIdentifier:@"UnwindToObjectManageSegue" sender:self]; } - (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)sender { return YES; } - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { return YES; } - (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier { ObjectManageObjectDetailSegue *segue = [[ObjectManageObjectDetailSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController]; [segue setUnwinding:YES]; return segue; }
解决方法
我有同样的问题,我终于找到了解决方案:
https://github.com/simonmaddox/CustomUnwindSegue
https://github.com/simonmaddox/CustomUnwindSegue
他也有一个问题,没有被召唤.事实证明,UINavigationController中的任何视图控制器都不会调用呈现视图控制器而是调用UINavigationController.这意味着您必须继承UINavigationController并在那里添加该方法.