gpt4 book ai didi

带有 dismissViewControllerAnimated 的 iOS 8 错误 : completion: animation?

转载 作者:可可西里 更新时间:2023-11-01 03:55:52 25 4
gpt4 key购买 nike

dismissViewControllerAnimated:completion: 的 iOS 文档指出:

If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

这意味着当使用一次关闭两个模态视图 Controller 时

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

显示的动画应该是被关闭的顶部模态视图。

在 iOS 7 和之前的版本中确实如此,但在 iOS 8 中显示的动画不是最顶层 View (根据我的经验,它是第二个最顶层 View )。这种行为是 iOS 8 中的错误还是我做错了什么?

最佳答案

如上评论:我在 unwind segue 上下文中看到了完全相同的问题。我只是使用屏幕截图按照此处所述的解决方法,并将其作为 subview 添加到所有中间 viewControllers:How to dismiss a stack of modal view controllers with animation without flashing on screen any of the presented VCs between the top and bottom?

    // 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;
}

关于带有 dismissViewControllerAnimated 的 iOS 8 错误 : completion: animation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28565237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com