I have a view that contains a counter.
I have implemented two different gesture recognizers,
a UISwipeGesture to increase the count by one,
and a UIPanGesture in order to increase the count by multiple numbers every
time the user swipes up.
Both gestures work, but my problem is they don't work at the same time.
I want them to work alternatively, for example if I do small swipes the
counter should increase by one, and if I keep dragging upwards the counter
should increase by multiple numbers.
Here's part of my code:
```
override func viewDidLoad() {
super.viewDidLoad()
setupSwipeGestures()
setupPanGestures()
}
private func setupSwipeGestures() {
let swipeUp = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))
let swipeDown = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))
swipeUp.direction = .Up
swipeDown.direction = .Down
circleView.addGestureRecognizer(swipeUp)
circleView.addGestureRecognizer(swipeDown)
}
private func setupPanGestures() {
let panGesture = UIPanGestureRecognizer(target: self, action: Selector("handleThePan:"))
circleView.addGestureRecognizer(panGesture)
}
extension UIPanGestureRecognizer {
func isDown(circleView: UIView) -> Bool {
let velocity : CGPoint = velocityInView(circleView)
if velocity.y < 0 {
print("ex Gesture went up")
return false
} else {
print("ex Gesture went down")
return true
}
}
}
```
P.S: The methods "handleSwipe" and "handlePan" contain the logic of the counter.
requireGestureRecognizerToFail
method. However, in your case, it seems like the two gesture recognizers would conflict. So you might consider just using a single gesture recognizer, then querying the velocity over time to see if the user is continuing to drag. – Naima