Reputation: 398
I am trying to pass through touches from a custom UIView to a UITableView underneath (the UIView is directly on top of the UITableView). However, it does not seem to be working.
In my custom UIView, I have tried all of the following (I'm using touchesMoved as an example but I've implemented this for all 4 touch methods)
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.nextResponder touchesMoved:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [super
touchesMoved:touches withEvent:event];
}
I've even tried passing a pointer to the UITableView directly into the custom UIView and doing this:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self.myTableView touchesMoved:touches withEvent:event];
}
None of these options seem to do anything as I can't scroll the UITableView. Any ideas why this wouldn't work?
Upvotes: 2
Views: 1525
Reputation: 64428
If the UIView is not a subview of the UITableView, it will not pass it touches up the responder chain to the UITableView.
However, the most likely culprit is a scrollview. Scrollviews trap all touches before sending them to subviews. This is backwards from the usual setup.
Since the UITableView uses a scrollview it is likely that the scrollview is trapping the touches before they get to UIView itself.
To test this, I suggest putting your UIView "over" i.e. make it a subview, of an ordinary view and get the responder chain to work like you wish. Then swap out the bottom/superview for a UITableView and see if it still works.
If it doesn't, the problem is the scrollview the table is imbedded in. I don't know a work around for that.
Upvotes: 1