diff --git a/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift b/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift index 4de68a3f..bfe74313 100644 --- a/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift +++ b/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift @@ -141,11 +141,13 @@ class EnhancedNavigationViewController: UINavigationController { if self.interactivePushTransition.interactive { // when an interactive push gesture is cancelled, make sure to adding the VC that was being pushed back onto the popped stack so it doesn't disappear self.poppedViewControllers.insert(self.interactivePushTransition.pushingViewController!, at: 0) - } else { + } else if self.interactivePopGestureRecognizer?.state == .ended { // when an interactive pop gesture is cancelled (i.e. the user lifts their finger before it triggers), // the popViewController(animated:) method has already been called so the VC has already been added to the popped stack // so we make sure to remove it, otherwise there could be duplicate VCs on the navigation stasck - self.poppedViewControllers.remove(at: 0) + if !self.poppedViewControllers.isEmpty { + self.poppedViewControllers.remove(at: 0) + } } } })