问题描述
我有一个侧面导航控制器并通过 UIButton 呈现它.当我通过 [self presentviewcontroller: NC animated: 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在转换过程中发生变化,它有点波涛汹涌,导航控制器和右上角的一部分变黑了.看起来很糟糕.
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
获取点击事件,设置containerView
的userInteractionEnabled
到 false
.这是如果您正在使用 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 阻止的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!