Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aduuub/25aec5f15940474fb8aa83f39ea8143e to your computer and use it in GitHub Desktop.
Save aduuub/25aec5f15940474fb8aa83f39ea8143e to your computer and use it in GitHub Desktop.
extension BaseNavigationController: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard gestureRecognizer == interactivePopGestureRecognizer else {
return true // default value
}
// Disable pop gesture in three situations:
// 1) the view controller doesn't support being popped or doesn't want to be popped right now
if let viewController = visibleViewController as? BaseViewControllerDelegate, viewController.preventInteractivePopGesture() {
return false
}
// 2) when there is only one view controller on the stack
// 3) when the pop animation is in progress
return viewControllers.count > 1 && self.duringPushAnimation == false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment