2
votes

Inside my navigation controller delegate I have following code:

- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                   animationControllerForOperation:(UINavigationControllerOperation)operation
                                                fromViewController:(UIViewController *)fromVC
                                                  toViewController:(UIViewController *)toVC {
    if ([toVC isKindOfClass:[ParentViewController class]]) {
        if (operation == UINavigationControllerOperationPush) {
            return [(ParentViewController *)toVC pushAnimator];
        }
    }
    return nil;
}

Push animator is implemented as following (some view controllers override it to implement custom transition):

- (id<UIViewControllerAnimatedTransitioning>)pushAnimator {
    return nil;
}

But after this default interactive pop animation is broken (but according to documentation if this method returns nil default animation will be used) even if I don't use custom transition for selected view controller.

How can I bring interactive pop gesture, but with custom push animations for some screens?

1
have you solved this? I have the same issueMichael Voline

1 Answers

0
votes

Just implement UIGestureRecognizerDelegate on view controller (or anything actually), and do

navigationController?.interactivePopGestureRecognizer?.delegate = self

it seems like you don't even have to implement anything, however you may want to try something like

func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
    return navigationController?.viewControllers.count ?? 0 > 1
}