My pure AutoLayout UITableViewCell
looks like this in Interface Builder:
UITableViewCell
|-> UITableViewCell.contentView
|-> UIView (ScrollViewContainerView)
|-> UIScrollView
|-> left (fixed)
|-> center (fill remaining)
|-> right (fixed)
The UIScrollView
contains a left
, center
, and right
UIView
. left
and right
are both fixed width, while center
expands to fill the remainder of the UIView
. The UIScrollView
constraints are to align all edges to ScrollViewContainerView
. ScrollViewContainerView
constraints are to align all edges to the UITableViewCell.contentView
. I have a constraint on center
's width to be a multiple of ScrollViewContainerView
's width, so the UIScrollView
scrolls left and right, but the height is fixed and does not scroll. Note that the UIScrollView
has been subclassed to include this code so that the UITableView
can detect a tap on the cell to toggle selection.
The issue is that I currently can either scroll the UITableView
containing these UITableViewCells
up and down or I can scroll the UIScrollViews
in the UITableViewCells
left and right, not both.
When ScrollViewContainerView.userInteractionEnabled == YES
, I can't scroll the UITableView
up and down, but I can scroll the UIScrollView left and right. When ScrollViewContainerView.userInteractionEnabled == NO
, I can scroll the UITableView
up and down, but I can't scroll the UIScrollView left and right. userInteractionEnabled == YES
on everything else in the above hierarchy.
I can get away with having ScrollViewContainerView
as a sibling view to the UIScrollView
(making the UIScrollView
the direct descent of contentView
-- can't get rid of this view completely, because I require it to get the dimensions for the UIScrollView
frame
). In that case, the opposite handling with userInteractionEnabled
holds.
I know I've done this before in other projects before, but starting fresh again, I can't seem to figure out what step I'm missing. Currently using Xcode 6 6A215l targeting iOS 8, though I have reproduced the issue under Xcode 5 targeting iOS 7.