在呈现后,视图被UITransitionView阻止 [英] View being blocked by UITransitionView after being presented
问题描述
我有一个侧导航控制器并通过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.
我附上了是另一个。
我尝试了以下内容:
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
.
示例,在<$ c中$ c> animateTransition(_:):
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView()
containerView.userInteractionEnabled = false
...
}
这篇关于在呈现后,视图被UITransitionView阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!