I have setup my UICollectionViewCell
with a UIPanGestureRecognizer
that should work like the ones you often see in UITableViewCells
that reveals controls underneath the content. My question should apply to both UICollectionViews
and UITableViews
though.
I have it working so that the horizontal pan in the cell works simultaneously with the vertical pan of the UICollectionView
. This is enabled simply by implementing this delegate method of UIGestureRecognizer
:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
This allows them to work simultaneously, but it also have the side effect that, as I am panning vertically in the UICollectionView
, any slight horizontal movement will trigger the gestureRecognizer
in the cell that I happened to touch while starting the vertical pan and thus revealing the underlying controls. I do not want this.
Mail handles this perfectly, so that fx. a vertical pan in the UITableView
, disables any horizontal pan gestures in the cells and vice versa.
Can I achieve this in a simple way by setting up my gesture recognizers correctly?
I'd like to avoid a solution where I have to manage state between the views ("Scroll view is dragging", "cell is dragging" etc).