带有dismissViewControllerAnimated的iOS 8错误:完成:动画?

Jam*_*mes 6 uiviewcontroller modalviewcontroller ios ios8

dismissViewControllerAnimated:completion:状态的iOS文档:

如果你目前在连续的几个视图控制器,从而构建呈现视图控制器的堆栈,调用视图控制器这种方法下的堆栈驳回其直接子视图控制器和堆栈上的孩子最重要的视图控制器.发生这种情况时,只有最顶层的视图以动画方式被删除; 任何中间视图控制器都可以从堆栈中删除.最顶层的视图使用其模态过渡样式被忽略,这可能与堆栈中较低的其他视图控制器使用的样式不同.

这意味着在使用时立即解除两个模态视图控制器

[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];

显示的动画应该是被解雇的顶级模态视图.

在iOS 7和之前的情况确实如此,但在iOS 8中,所显示的动画并不是最顶级的视图(根据我的经验,它是第二个最顶层的视图).这种行为是iOS 8中的错误还是我做错了什么?

the*_*guy 3

如上所述:我在 unwind segue 上下文中看到了完全相同的问题。我只是使用屏幕截图采用此处描述的解决方法,并将其作为子视图添加到所有中间 viewControllers:如何用动画消除一堆模态视图控制器,而不在屏幕上闪烁顶部和底部之间任何呈现的 VC?

    // this in during unwind in a custom UIStoryboardSegue (that is the reason why it might look wrong with what is what: srcViewController and destViewController
    UIViewController* aPresentedViewController = destViewController.presentedViewController;
    while (aPresentedViewController != nil) {
        if (aPresentedViewController == srcViewController) {
            break;
        }
        UIView *anotherSrcViewCopy = [srcViewController.view snapshotViewAfterScreenUpdates: NO];
        anotherSrcViewCopy.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        [aPresentedViewController.view addSubview:anotherSrcViewCopy];
        // recurse through the presentedViewController hierarchy
        aPresentedViewController = aPresentedViewController.presentedViewController;
    }
Run Code Online (Sandbox Code Playgroud)