I have a view that is presented modally. This comes with the iOS 13/14 swipe down to dismiss feature.
When the user has started to dismiss the modal view, I get this delegate call:
func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
}
This gets called as soon as the user has started to drag the view down. However, it can get cancelled.
Following call gives me once the view has done dismissing:
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
}
What I need is to know when the user has finished the gesture to dismiss and the view will be finishing the dismissal.
I was able to take it few steps forward, but still missing the above-required detection:
func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
//User started dismissing, with no guarantee
self.transitionCoordinator!.animate(alongsideTransition: {(context: UIViewControllerTransitionCoordinatorContext) -> Void in
//Dismissal is animating. Could be finishing or canceling the dismissal
}, completion: {( context: UIViewControllerTransitionCoordinatorContext) -> Void in
if context.isCancelled {
//Dismissal got cancelled
} else {
//Dismissal has completed. Too Late!
}
})
}
willDismiss
and grab the transition coordinator. So that may be the best you can do. Short of throwing out the baby with the bath water and turning this into a full screen presentation, of course. – matt