Search code examples
iosswiftuitableviewgesture

leadingSwipeActions conflict with custom gesture


I have a view on tableView and added UIPanGestireRecognizer to that view.

And on my tableView I have a swipe action realized with

tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath)

but it works bad. Most of the time my panGesture works instead of swipe action. How can I fix this?


Solution

  • Try to implement UIGestureDelegate and check.

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    
        if gestureRecognizer.view == YourView {
            return true
        }
        return false
    }