ios - 为 UINavigationController 展开 Segue

标签 ios uistoryboardsegue

我有一个简单的 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/

相关文章:

ios - KERN_INVALID_ADDRESS 位于 0x0000000000000000

iOS 无损图像编辑

ios - 为什么触发 unwind segue 的按钮会立即消失?

ios - SWRevealViewController 如何修复 popoViewController 的工作?

ios - 设置 UIStoryboardSegue 子类的属性 [模态 segue 上的可选动画]

ios - 谁能告诉我函数的影响是什么?

ios - 核心数据 : "Cannot delete object that was never inserted."

iphone - stretchableImageWithLeftCapWidth 导致角落模糊

ios - 如何阻止自定义 UIStoryboardSegue 末尾的 "flashing" View ?

objective-c - 防止在 segue 中关闭 View Controller