Custom transition animation not calling VC lifecycle methods on dismiss

Another solution could be using beginAppearanceTransition: and endAppearanceTransition:. According to documentation:

If you are implementing a custom container controller, use this method
to tell the child that its views are about to appear or disappear. Do
not invoke viewWillAppear:, viewWillDisappear:, viewDidAppear:, or
viewDidDisappear: directly.

Here is how I used them:

- (void)animationEnded:(BOOL)transitionCompleted
{
    if (!transitionCompleted)
    {
        _toViewController.view.transform = CGAffineTransformIdentity;
    }
    else
    {
        [_toViewController endAppearanceTransition];
    }
}

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

    [toViewController beginAppearanceTransition:YES animated:YES];
    // ... other code
}

But I still consider strange that custom modal presentation not doing this.

Leave a Comment