I have a UITableView
which is a subview of a UIView
, then that UIView
is a subview of a UIScrollView
. How do I detect the touches that should scroll the UITableView
?
The UITableView
can get item selection events (a cell in the table is selected/tapped) just fine, except that you have to hold down on the cell before it fires. But I can't get the UITableView
to scroll, its always the UIScrollView
that reacts to the pan gesture.
Any help is greatly appreciated. Thanks in advance!
EDIT:
Solved, though I asked the wrong question. It does work by default as Roman K pointed out. I think the problem was related to having a part of the UITableView
outside the bounds of the UIScrollView
(the UITableView
went over the bottom bounds of the UIScrollView
). Setting it to correctly fit inside the UIScrollView
fixed it.
Please, make sure that UIScrollView's
properties delaysContentTouches
and canCancelContentTouches
are set appropriately. They control how UIScrollView instance passes touch information to its subviews. By default delaysContentTouches
is set to YES. Also, make sure that, if you extended UIScrollView
, touchesShouldBegin:withEvent:inContentView:
allow touches in the subview.
Otherwise, UITableView
scrolling should work by default in your scenario. If you create a test project with just the view hierarchy as described you will see that it is the case. So, compare the two and see what difference affects the scrolling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With