From 7c5076d01ab2ece220809837759b6af35b21bbab Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 21 Sep 2021 23:30:38 -0400 Subject: [PATCH] Fix dismissing gallery presented by modally-presented VC removing the gallery's presenting VC from the view hierarchy Closes #132 --- .../LargeImageShrinkAnimationController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift b/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift index 60612105..cad711e6 100644 --- a/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift +++ b/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift @@ -68,6 +68,12 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra blackView.backgroundColor = .black blackView.alpha = 1 + // Save the old superview of toVC so we can move it back after the animation. + // It would be better to just not move toVC and instead remove from fromVC from the + // containerView so that toVC is visible behind it, but that doens't work for some reason + // (the entire screen just goes black, not even the contents of the containerView appear). + let oldSuperview = toVC.view.superview + containerView.addSubview(toVC.view) containerView.addSubview(blackView) containerView.addSubview(imageView) @@ -88,6 +94,9 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra sourceView.alpha = 1 transitionContext.completeTransition(!transitionContext.transitionWasCancelled) + + // move the toVC back to the view that it was in before + oldSuperview?.addSubview(toVC.view) }) }