segueForUnwindingToViewController为不正确的父视图控制器抛出异常

时间:2014-06-27 20:37:32

标签: ios iphone objective-c segue uistoryboardsegue

我正在尝试为展开过渡运行自定义segue。有一个整体导航控制器和两个子视图(ViewAViewB)。我试图通过以下代码返回这些代码(通过按钮和故事板反向segue触发):

// XXXNavigationController.h

- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)
toViewController fromViewController:(UIViewController *)
fromViewController identifier:(NSString *)identifier {
    UIViewController *controller = self.topViewController;
    return [controller segueForUnwindingToViewController:toViewController
                                      fromViewController:fromViewController
                                              identifier:identifier];
}

// XXXViewBController.h (in a reverse segue, going ViewB -> ViewA)

- (UIStoryboardSegue *)
segueForUnwindingToViewController:(UIViewController *)toViewController 
fromViewController:(UIViewController *)fromViewController 
identifier:(NSString *)identifier
{
    XXXReverseZoomSegue *segue = [[XXXReverseZoomSegue alloc] 
                                 initWithIdentifier:identifier 
                                             source:fromViewController 
                                        destination:toViewController];
    return segue;
}

目前导致以下异常:

*** Terminating app due to uncaught exception 
'UIViewControllerHierarchyInconsistency', reason: 
'child view controller:<XXXViewAController: 0x14c5119e0> 
 should have parent view controller:<XXXViewBController: 0x15000b400>
 but actual parent is:<XXXNavigationController: 0x14c5116a0>'

如何正确设置,以便我可以使反向segue工作?

0 个答案:

没有答案