视图在呈现后被 UITransitionView 阻止 [英] View being blocked by UITransitionView after being presented

本文介绍了视图在呈现后被 UITransitionView 阻止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个侧面导航控制器并通过 UIButton 呈现它.当我通过 [self presentviewcontroller: NC animation: YES completion: nil] 直接将此 NC 设为根视图控制器时,由于某种原因,NC 的菜单侧被 UITransitionView 阻塞> 我无法消失.

I have a side navigation controller and present it via a UIButton. When I make this NC the root view controller directly by [self presentviewcontroller: NC animated: YES completion: nil], some reason the menu side of the NC is blocked by a UITransitionView that I cannot get to disappear.

我附上了 . 是另一个.

I've attached an image of the . is another.

我尝试了以下方法:

UIWindow *window = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
    window.backgroundColor = kmain;


    CATransition* transition = [CATransition animation];
    transition.duration = .5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromTop;

    [nc.view.layer addAnimation:transition forKey:kCATransition];

    [UIView transitionWithView:window
                      duration:0.5
                       options:UIViewAnimationOptionTransitionNone
                    animations:^{ window.rootViewController = nc; }
                    completion:^(BOOL finished) {
                        for (UIView *subview in window.subviews) {
                            if ([subview isKindOfClass:NSClassFromString(@"UITransitionView")]) {
                                [subview removeFromSuperview];
                            }
                        }
                    }];

但它非常hacky,并且随着窗口的rootviewcontroller在转换过程中发生变化,它有点断断续续,并且navigationcontroller的一部分和右上角变黑.看起来很糟糕.

But it is very hacky, and as the rootviewcontroller of the window changes during the transition, it's a little choppy and part of the navigationcontroller and the top right corner turn black. It looks very bad.

推荐答案

要通过UITransitionView获取点击事件,设置containerViewuserInteractionEnabledfalse.这是如果您使用 UIViewControllerAnimatedTransitioning 制作自定义过渡动画.

To get tap events through the UITransitionView, set the containerView's userInteractionEnabled to false. This is if you're doing a custom transition animation by using UIViewControllerAnimatedTransitioning.

例如,在您的 animateTransition(_:):

func animateTransition(transitionContext: UIViewControllerContextTransitioning) {

    let containerView = transitionContext.containerView
    containerView.isUserInteractionEnabled = false

    ...
}

这篇关于视图在呈现后被 UITransitionView 阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆