1
votes

I have a custom UIView subclass that has a UITapGestureRecognizer attached to it. I am trying to use this custom view inside of a UIView (container) inside of a UIScrollView, inside of a UITableViewCell.

So:

UITableViewCell

•UIScrollView

••UIView (container for proper contentSize on UIScrollView)

•••Bunch of UIViews with UITapGestureRecognizer (subclass)

It seems that if I don't use a 'container' view inside the UIScrollView, the taps get detected just fine. But then the contentSize is not correct and some of my custom views inside the UIScrollView are off screen and can't be accessed.

If I do use a 'container' view inside the UIScrollView, the contentSize for the scroll view is correct, but none of the custom view taps get detected.

I have tried all sorts of variations of the below with no success:

tapGesture.cancelsTouchesInView = false
scrollView.canCancelContentTouches = false
scrollView.userInteractionEnabled = true
containerView.userInteractionEnabled = true
1

1 Answers

0
votes

Well I couldn't get it to work for some reason, even tried subclassing UIScrollView and the UIView for the container view.

I ended up just adding a UICollectionView to the subclassed UITableViewCell, and then setting the UITableViewController as the UICollectionViewDataSource and UICollectionViewDelegate to handle item selection.