-
Notifications
You must be signed in to change notification settings - Fork 140
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
Attaching a tableview, the swipe cell action doesn't work #60
Comments
Hi, I have the same problem. I have a table view inserted and it does not detect the click on the cell correctly, there is something that blocks it. |
I've solved in this way: in setupPanGestureRecognizer() in the PullUpViewController add the delegate to the gesture private func setupPanGestureRecognizer() {
addInternalScrollViewPanGesture()
panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePanGestureRecognizer(_:)))
panGestureRecognizer?.minimumNumberOfTouches = 1
panGestureRecognizer?.maximumNumberOfTouches = 1
panGestureRecognizer?.delegate = self
if let panGestureRecognizer = panGestureRecognizer {
view.addGestureRecognizer(panGestureRecognizer)
}
} than, always in the PullUpViewController file add this extension: extension PullUpController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
guard let _ = otherGestureRecognizer as? UIPanGestureRecognizer, let current = gestureRecognizer as? UIPanGestureRecognizer else {
return false
}
let velocity = current.velocity(in: self.view)
return abs(velocity.x) >= abs(velocity.y);
}
} this allows multiple gestures simultaneously if:
You can modify the delegate as you prefer. Than in the handlePanGestureRecognizer after the guard add this if statement, this prevents to scroll down the controller when you are doing a not so perfect horizontal swipe @objc private func handlePanGestureRecognizer(_ gestureRecognizer: UIPanGestureRecognizer) {
guard
isPortrait,
let topConstraint = topConstraint
else { return }
let xVelocity = gestureRecognizer.velocity(in: self.view).x
let xTranslation = gestureRecognizer.translation(in: view).x
if abs(xVelocity) > 0 || abs(xTranslation) > 0 { return }
...
} |
Hi @AndreaMiotto, |
Thanks, added the pull request, please test it before the merge. Just use a table view as scroll view and add some swipe action to the cells. |
Hi, I've added all the necessary changes listed above in my PullUpController, but it still doesn't recognize the swipe action gesture. Any idea as to what's going on? |
Hi, I'm using the pullUpController with a tableview that is attached with the proper func.
I really have the need to add edit cel action that is performed with the swipe. But apparently there is something with the pullUpController that is blocking the swipe gesture
The text was updated successfully, but these errors were encountered: