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?
Asked
Active
Viewed 282 times
1

childrenOurFuture
- 1,889
- 2
- 14
- 23
1 Answers
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
-
sorry, my description fault, I add pan gesture on background view, and I need user do operation on the background view. – childrenOurFuture Jul 15 '16 at 02:38
-
@childrenOurFuture Updated my answer. – Lumialxk Jul 15 '16 at 02:46
-
I know what you said ,thx a lot. my concern is not about that, I focus on how to control the response chain of it. how to let background view's gesture can get user's operation. – childrenOurFuture Jul 15 '16 at 02:54
-
@childrenOurFuture Updated my answer with how to change responder chain. – Lumialxk Jul 15 '16 at 03:04