Pass UITableView default PanGesture to another UIView

19 Views Asked by At

I have an UITableView, vertically covered over a UIView and that View have UIPangestureRecognizer. Now if user try to scroll tableView and if finger point have no cell I want second views panGesture response.

1

There are 1 best solutions below

0
Kazi Abdullah Al Mamun On BEST ANSWER

Subclass UITableView and override hitTest method.

-> if finger point have cell return self

-> else return nil or any other view that should response

Code:

class MyTableView: UITableView {
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        if indexPath(at: point) != nil {
            retrn self
        } else {
            return nil
        }
    }
}