View controller dismisses by swiping down on it.

I have a view controller that can be swiped down to get out of. The problem is, I need the user to get out of the view controller by pressing a bar button item that goes to an unwind function. The bar button items are hidden by the search controller. I need to either make a way for the user to hide the search controller or put code that triggers when the view controller is dismissed by swiping down on it. Is there a callback function that is called when the view controller is dismissed like that? How would I do either of those? Another question: Is there a way to make the view controller so that it's not able to be dismissed by swiping down on it like that?

You can set a delegate on the presented view controllers presentation controller, check out the methods in UIAdaptivePresentationControllerDelegate. presentationControllerWillDismiss(_:) is called when the user dismisses the view controller by swiping down.

If you want to prevent the user from dismissing by swiping down you can either set isModalInPresentation to true on the view controller or return false in presentationControllerShouldDismiss(_:).
View controller dismisses by swiping down on it.
 
 
Q