Skip to content

Commit

Permalink
Merge pull request #222 from atlassian/bugfix/animation-transition-be…
Browse files Browse the repository at this point in the history
…gin-end

Fix: Parent's `viewWillAppear` etc. methods are not getting called
  • Loading branch information
yorkepb authored Oct 7, 2019
2 parents 533a1fa + 675f97d commit a6d27dd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions NYTPhotoViewer/NYTPhotoTransitionAnimator.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
@interface NYTPhotoTransitionAnimator ()

@property (nonatomic, readonly) BOOL shouldPerformZoomingAnimation;
@property (nonatomic, weak) UIViewController *toViewController;
@property (nonatomic, weak) UIViewController *fromViewController;

@end

Expand Down Expand Up @@ -46,8 +48,12 @@ - (void)setupTransitionContainerHierarchyWithTransitionContext:(id <UIViewContro
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];

UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
toView.frame = [transitionContext finalFrameForViewController:toViewController];
self.toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
self.fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];

toView.frame = [transitionContext finalFrameForViewController:self.toViewController];
[self.toViewController beginAppearanceTransition:YES animated:YES];
[self.fromViewController beginAppearanceTransition:NO animated:YES];

if (![toView isDescendantOfView:transitionContext.containerView]) {
[transitionContext.containerView addSubview:toView];
Expand Down Expand Up @@ -253,6 +259,10 @@ + (UIView *)newAnimationViewFromView:(UIView *)view {
}

#pragma mark - UIViewControllerAnimatedTransitioning
- (void)animationEnded:(BOOL)transitionCompleted {
[self.toViewController endAppearanceTransition];
[self.fromViewController endAppearanceTransition];
}

- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
if (self.shouldPerformZoomingAnimation) {
Expand Down

0 comments on commit a6d27dd

Please sign in to comment.