Open Sabellus opened 3 years ago
I haven't tried this myself yet, but you will need to manage the gesture recognizers yourself. See https://developer.apple.com/documentation/uikit/touches_presses_and_gestures/coordinating_multiple_gesture_recognizers
Will leave this open in case anyone else has tried this and can offer some help
any update?
Hi,
I added scrollview inside swipe card. The code is like, I added only difference parts.
1-) **TinderCardContentView*****
private func initialize() { let scrollViewPanGesture = UIPanGestureRecognizer() scrollViewPanGesture.addTarget(self, action:#selector(self.handle(gesture:))) scrollViewPanGesture.delegate = self scrollView.addGestureRecognizer(scrollViewPanGesture) ....... ....... .... }
extension TinderCardContentView : UIGestureRecognizerDelegate{ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true } }
**TinderCardContentView*****
2-) **SwipeView*****
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { return false } **SwipeView*****
3-) **SwipeCardStack*****
open var shouldRecognizeVerticalDrag: Bool = false
override open func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { guard let topCard = topCard, topCard.panGestureRecognizer == gestureRecognizer else { return super.gestureRecognizerShouldBegin(gestureRecognizer) }
let velocity = topCard.panGestureRecognizer.velocity(in: self)
let translation = topCard.panGestureRecognizer.translation(in: topCard.superview)
if abs(velocity.x) > 0 {
if abs(translation.x) > 1{
return shouldRecognizeHorizontalDrag
}else{
return shouldRecognizeVerticalDrag
}
}
else{
return false
}
}
**SwipeCardStack*****
@mac-gallagher any ideas?