diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 6d789b72..1a58ec06 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -109,8 +109,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated itemViewController.addContent() transitionContext.completeTransition(true) - - to.presentationAnimationCompleted() } animator.startAnimation() @@ -132,8 +130,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated } animator.addCompletion { _ in transitionContext.completeTransition(!transitionContext.transitionWasCancelled) - - to.presentationAnimationCompleted() } animator.startAnimation() } diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift index 7d238ef5..825084d0 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift @@ -68,6 +68,17 @@ public class GalleryViewController: UIPageViewController { setViewControllers([makeItemVC(index: initialItemIndex)], direction: .forward, animated: false) } + public override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + if animated { + // Wait until the transition is no longer in-progress, otherwise things will just get deferred again. + DispatchQueue.main.async { + self.presentationAnimationCompleted() + } + } + } + public override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated)