Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i use scrollview inside swipecard? #143

Open
Sabellus opened this issue May 1, 2021 · 4 comments
Open

how can i use scrollview inside swipecard? #143

Sabellus opened this issue May 1, 2021 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@Sabellus
Copy link

Sabellus commented May 1, 2021

@mac-gallagher any ideas?

@Sabellus Sabellus added the bug Something isn't working label May 1, 2021
@mac-gallagher mac-gallagher added help wanted Extra attention is needed and removed bug Something isn't working labels May 1, 2021
@mac-gallagher
Copy link
Owner

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

@mac-gallagher
Copy link
Owner

Will leave this open in case anyone else has tried this and can offer some help

@BayramInanc
Copy link

any update?

@BayramInanc
Copy link

BayramInanc commented Nov 24, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants