[Question] how to forbid the sliding gestures in subview
EternalChildren opened this issue · comments
New Issue Checklist
- I read the documentation.
- I searched for existing GitHub issues.
- I searched Google for a solution to my issue if applicable.
Question
i have a view struct likes
JPMain(extends VerticalCardSwiperDelegate) --> JPCell(CardCell) --> Canvas(UIView in JPCell)
i try to control the cell gesture, hope to forbid the sliding up or down. then i find a nice solution that modify the below function
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool
but i failed. so i want to know how to forbid the sliding gestures for VerticalCardSwiper. looks like it’s here
extension VerticalCardSwiper: UIGestureRecognizerDelegate
expected:
i want the VerticalCardSwiper can't slide up or down when i handle some gesture in Canvas
Can you help me?
Have you tried using cardSwiper.verticalCardSwiperView.isScrollEnabled = false
?
Or are the gesturerecognizers interfering?
i have solve it by the below way
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
let superview = self.superview as? VerticalCardSwiperView
superview?.isScrollEnabled = true
if let target = touch.view {
if target.isDescendant(of: canvas) {
superview?.isScrollEnabled = false
return false
}
}
return true
}
But i am sure it's the best way because it should set isScrollEnabled = true lots of times
what's the gesture recognizers interfering?