I\'m writing a module that everytime I swipe on a view, two sub views with a half size of the view will be added. Those subviews have their own gestures (eg: pan,...). The f
Took what I read here and made a Swift 5 that works great (for me)! I have a slide control in a view that also has a swipe recognizer for moving to another view. If the finger doesn't hit the slider's thumb, then the whole view moves.
By placing this view under the slider (expanded so its somewhat bigger), misses don't do anything.
final class BlockingView: UIView, UIGestureRecognizerDelegate {
let swipe: UISwipeGestureRecognizer = UISwipeGestureRecognizer();
init() {
super.init(frame: CGRect.zero)
swipe.direction = [.left, .right]
self.addGestureRecognizer(swipe)
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
@objc override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { return false }
}
Hope this saves someone the trouble!