I have a detent set in my VC, as a swip-panel on another ViewController (anotherVC) and in certain situations I want to freeze \ disable it from moving up and down...
func viewDidLoad() {
if let sheet = anotherVC.sheetPresentationController {
sheet.detents = [.medium(), .large()]
sheet.delegate = self
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
sheet.prefersGrabberVisible = true
self.present(anotherVC, animated: true)
}
}
HOW DO I DISABLE THE DETENT FROM MOVING (up and down)?
In order to prevent the vc / sheet (with the detent) from disappearing & closing, set the isModalInPresentation property to TRUE.
In order to prevent the detent from moving to different sizes, make sure there's only one detent in the array.
here is the code:
if let sheet = anotherVC.sheetPresentationController {
//only 1 detent in the array:
sheet.detents = [.medium()]
//prevents from the mini-view to close:
sheet.presentedViewController.isModalInPresentation = true
}