UITableView in UIScrollView not responding to first tap after scroll
As answered here, the correct solution (if you're not one to follow the rules) is to keep scrollEnabled
set to YES
on all embedded tableViews. This lets them handle the touches properly. But be sure to set bounces
to NO
on the embedded views to avoid weird scrolling behavior.
UITableView inside UIScrollView - Cell not clickable
Do the following thing:
yourView.clipToBounds = true
Now, if UITableView
does not appears means your UIView
is not same bigger to hold down UITableView
.
Make sure that your UIView
height is bigger to hold the contents in it and then try to tap on it.
Updated:
If you are using AutoLayout
, then do the following thing.
- Give the fix height to
UIView
- Take the outlet of height constraint of
UIView
Now, in
viewDidLayoutSubviews
change the constraint ofUIView
toUITableView
contentSize
height.self.heightConstraint = self.tableView.contentSize.height
Let me know, if this helps!
UITableView tap not working first time after constraints change
After trying to figure out a solution to this without result, we (me and a UX designer) decided to change the behaviour a bit.
So in the real scenario in the app I'm implementing this in, the table view is inside another view that has also a title label and some other views above the table view. We decided to add a pan gesture recognizer to this root view and disable the scrolling of the table view when the view has the min size. This way the pan gesture recognizer will take over whenever the user tries to drag anywhere inside the view (including the table view), so the expanding of the view works. And the tap in the cell still works.
When the view has the max height the table view scroll is enabled so the user can scroll. The downside of this approach is that when the user scrolls to the top of the table view and continues scrolling the view will not decrease the size. But he still has the option to drag it down by dragging any of the views above the table view. When dragging down in this way, only the size of the table view changes, and the content offset isn't, which is the root of the problem (changing both at the same time).
UITableView scrolling problems when inside a UIScrollView
Things I would check:
- Check your View Hierarchies - Is something being laid on top of your UITableView, causing it not to receive a tap?
- Are your UITableViews being disabled anywhere? I would set a breakpoint in
tableView:didSelectRowAtIndexPath:
and see if that method is being called. - Check this post
I guess those aren't sure-fire answers but hopefully they'll help discover the problem!
Row selection doesn't work on first tap after scroll in a non-bouncing UITableView
After a lot more testing, I found that the problem happens when the table's contentOffset.y
reaches maximum value or 0. So I created my own "bouncing effect" but on a much smaller scale by implementing scrollViewWillEndDragging:withVelocity:targetContentOffset:
in the table view's delegate as follows:
-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
targetContentOffset->y = MAX(targetContentOffset->y -1, 1);
}
With that in place, the problem disappeared. It's a workaround but works like a charm!
Related Topics
Using Ldap for Authentication in iOS
Send Programmatically Sms on Jailbreak Device
Urlsession.Datatask with Request Block Not Called in Background
How to Round Corners of Uiimage with Hexagon Mask
Record Audio and Save Permanently in iOS
Swift 3 - Comparing Date Objects
Cocoa-Touch: How to See If Two Nsdates Are in the Same Day
Change Button Background Color Using Swift Language
Uibutton That Resizes to Fit Its Titlelabel
App Icons Not Included in Build from Xcode
Uicollectionview - Diddeselectitematindexpath Not Called If Cell Is Selected
In Call Status Bar (Unable to Satisfy Constraints)
How to Use Cgaffinetransformmakerotation
How to Get Only Images in the Camera Roll Using Photos Framework