1

I would like to use a UIView as a UITableView's background view, and I set the UITableView's content inset, so user can scroll down the table view to show the background view,also I need to add pan and drag gesture on the background view to let user do some operation, but I found it seems not work.
Does any one have a good solution to do it?

childrenOurFuture
  • 1,889
  • 2
  • 14
  • 23

1 Answers1

1

UITableView has its own panGestureRecognizer. So it call scroll up and down. You should use this rather than adding new gesture.
Updated:
Although you scroll down table view and make background view visible, it's in table view's frame and touch events should handled by table view. In one word, what decides response is frame.
How to solve this

Try do this in view controller:

 override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        if let touch = touches.first {
            if let tableView = touch.view as? UITableView {
                if tableView.contentOffset.y < tableView.contentInset.top {
                    let point = touch.locationInView(backgroundView)
                    backgroundView.hitTest( point, withEvent: event)
                }
            }
        }
    }
Lumialxk
  • 6,239
  • 6
  • 24
  • 47