Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View being blocked by UITransitionView after being presented

Tags:

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 view hierarchy. Here is another.

I have tried the following:

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

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.

like image 747
Jameson Avatar asked Mar 21 '16 22:03

Jameson


Video Answer


1 Answers

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.

Example, in your animateTransition(_:):

func animateTransition(transitionContext: UIViewControllerContextTransitioning) {      let containerView = transitionContext.containerView     containerView.isUserInteractionEnabled = false      ... } 
like image 81
SpencerBaker Avatar answered Sep 28 '22 04:09

SpencerBaker