When I embed a custom UIControl inside a ViewController that's presented modally with the new iOS13 automatic style, touchesCancelled
is called whenever a pan gesture moves more than a few points.
The native UIKit
UISlider
doesn't do this. You can pan a UISlider within an automatic
style modal ViewController without issue.
UIScrollView has touchesShouldCancel(in view: UIView)
where you can force it to allow touches in specified views but I can't find anything in the docs for this new style of modal presentation.
You can implement gestureRecognizerShouldBegin
of UIGestureRecognizerDelegate
on your UIControl
and return false
if it is of UIPanGestureRecognizer
//MARK: UIGestureRecognizerDelegate
extension RangeSlider: UIGestureRecognizerDelegate {
public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return !(gestureRecognizer is UIPanGestureRecognizer)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With