被呈现后被UITransitionView阻止的视图
我有一个侧面导航控制器,并通过UIButton呈现。 当我通过[self presentviewcontroller: NC animated: YES completion: nil]
直接将这个NC视图控制器作为根视图控制器[self presentviewcontroller: NC animated: YES completion: nil]
,由于某种原因,NC的菜单端被一个UITransitionView
阻塞,我无法消失。
我附上了一张图片 。 是另一个。
我已经尝试了以下内容:
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在转换过程中发生变化,它有点波涛汹涌,导航控制器的一部分和右上angular变成黑色。 它看起来非常糟糕。
要通过UITransitionView
获取点击事件,请将containerView
的userInteractionEnabled
为false
。 这是如果你正在使用UIViewControllerAnimatedTransitioning
做一个自定义的过渡animation。
例如,在你的animateTransition(_:)
:
func animateTransition(transitionContext: UIViewControllerContextTransitioning) { let containerView = transitionContext.containerView() containerView.userInteractionEnabled = false ... }
我有同样的问题,但在一个不同的情况下,我做了一些非常相似的东西find视图,而不是删除视图,这可能是更多的问题,我禁用用户交互,所以任何触摸事件只是扔它和其他对象可以处理用户的交互。 在我的情况下,这只是在更新到iOS 10的应用程序之后,iOS 9中运行的相同的代码不属于这个。
最好的,删除UITransitionView,要清楚
使用此行代码SWIFT 3.0
@IBAction func MoveBack(_ sender: Any) { dismiss(animated: true, completion: nil) }