Touches not recognized after custom transition
Asked Answered
E

1

1

I have an issue with custom transitions on the iPad. I create a custom transition that animates correctly and seems to work (i.e. the transition occurs). However, when I arrive at the destination view controller (after executing the isLoggedIn block), the destination view controller is unresponsive (it doesn't respond to touch events). II have a feeling it has something to do with the call to [container insertSubview:toViewController.view belowSubview:fromViewController.view]; because if I call [container insertSubview:toViewController.view aboveSubview:fromViewController.view]; the touches work as expected (but you cannot see the animation, as it happens on the source view controller).

Any idea why the touch events aren't being recognized?

-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *container = [transitionContext containerView];

//Prepare the view
if (self.isLoggedIn) {
    //Insert the main view under the login view
    CGRect frame = CGRectMake(0, 0, toViewController.view.frame.size.height,
                              toViewController.view.frame.size.width);
    toViewController.view.frame = frame;
    [container insertSubview:toViewController.view belowSubview:fromViewController.view];
} else {
    CGRect frame = CGRectMake(0, 0, toViewController.view.frame.size.height,
                              toViewController.view.frame.size.width);
    toViewController.view.frame = frame;
    if([toViewController respondsToSelector:@selector(openWalls)]) {
        [(DJVLoginViewController*)toViewController openWalls];
    }
    if([toViewController respondsToSelector:@selector(toggleLoginViewsAlpha:)]) {
        [(DJVLoginViewController*)toViewController toggleLoginViewsAlpha:0];
    }
    //Insert the login view above the main view
    [container insertSubview:toViewController.view aboveSubview:fromViewController.view];
}

//Make animations

[UIView animateWithDuration:[self transitionDuration:transitionContext]
                 animations:^{
                     if (self.isLoggedIn) {
                         //Perform animation
                     } else {
                         //Perform animation
                     }
                 } completion:^(BOOL finished) {
                     [transitionContext completeTransition:YES];
                 }];
}
Eraeradiate answered 10/3, 2014 at 12:24 Comment(2)
Try to remove first view from superview when finished animation.Qadi
Be sure that 1. is there any view on top of that view. 2. userInteraction is enabled for that view.Psychotechnology
Q
1

Try to remove fromView from superview:

[UIView animateWithDuration:[self transitionDuration:transitionContext]
                 animations:^{
                     if (self.isLoggedIn) {
                         //Perform animation
                     } else {
                         //Perform animation
                     }
                 } completion:^(BOOL finished) {
                     [fromViewController.view removeFromSuperview];
                     [transitionContext completeTransition:YES];
                 }];
}
Qadi answered 10/3, 2014 at 12:37 Comment(1)
Thanks, that worked - I had tried calling [fromViewController removeFromParentViewController]; but I was obviously making a mistake.Eraeradiate

© 2022 - 2024 — McMap. All rights reserved.