我有一个简单的 UINavigationController,它通过自定义 segue 将 UIViewController 推送到堆栈上。然后,我在第一个 UIViewController 上实现了一个 IBAction 来执行展开操作,并实现了 segueForUnwindingToViewController。不幸的是,没有调用 segueForUnwindingToViewController(我确实确认在第一个 VC 上调用了 canPerformUnwindSegue)。
我还没有看到这种行为的任何简单示例。有人可以帮忙吗?谢谢。
这是来自 NavigationController 的 Root View Controller 的代码。
- (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
他也遇到了没有被调用的问题。事实证明,UINavigationController 中的任何 View Controller 都不会调用呈现 View Controller ,而是调用 UINavigationController。这意味着您必须将该 UINavigationController 子类化并在其中添加该方法。
关于ios - 为 UINavigationController 展开 Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16092189/