Kazi Abdullah Al Mamun
Kazi Abdullah Al Mamun

Reputation: 1481

Pass UITableView default PanGesture to another UIView

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.

Upvotes: 0

Views: 21

Answers (1)

Kazi Abdullah Al Mamun
Kazi Abdullah Al Mamun

Reputation: 1481

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
        }
    }
}

Upvotes: 0

Related Questions