How to have a UISwipeGestureRecognizer AND UIPanGestureRecognizer work on the same view

后端 未结 4 1110
春和景丽
春和景丽 2020-12-04 19:58

How would you setup the gesture recognizers so that you could have a UISwipeGestureRecognizer and a UIPanGestureRecognizer work at the same

4条回答
  •  萌比男神i
    2020-12-04 20:40

    By default, when the user attempts to swipe, the gesture is interpreted as a pan. This is because a swiping gesture meets the necessary conditions to be interpreted as a pan (a continuous gesture) before it meets the necessary conditions to be interpreted as a swipe (a discrete gesture).

    You need to indicate a relationship between two gesture recognizers by calling the requireGestureRecognizerToFail: method on the gesture recognizer that you want to delay

    [self.panRecognizer requireGestureRecognizerToFail:self.swipeRecognizer];
    

提交回复
热议问题