0

I create ClothesCollectionView that contains ClothesCollectionViewCell elements. One of the element is called JeansCollectionViewCell and is a collectionView on its own. This image probably makes it easier to understand

enter image description here

1 is ClothesCollectionView, 2 is JeansCollectionViewCell and 3 are cell on JeansCollectionViewCell called JeanItemCell.

When a JeanItemCell is selected, the delegate didSelectItemAt of ClothesCollectionView gets called but not the one of JeansCollectionViewCell, so I can not determine which JeanItemCell was selected.

EDIT:

I added this code found here to JeansCollectionViewCell

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
    let hitTargetView = super.hitTest(point, with: event)
    return hitTargetView as? UIControl ?? (hitTargetView == self ? nil : superview)
}

override func didMoveToSuperview() {
    superview?.addGestureRecognizer(collectionView.panGestureRecognizer)
}

Now, with this code, I am able to scroll horizontally on JeansCollectionViewCell which was not the case, but unfortunately also outside the cell. Everywhere from ClothesCollectionView I can scroll horizontally the Jeans items. I am still not able to detect taps on the items.

Community
  • 1
  • 1
J.Doe
  • 697
  • 2
  • 16
  • 26
  • 1
    Did you _set_ a delegate for the JeansCollectionView? – matt Mar 08 '17 at 15:57
  • Sure, datasource and delegate. – J.Doe Mar 08 '17 at 16:01
  • What if you set the outer collection view's delegate to return `false` from `collectionView(_:shouldSelectItemAt:)` for this cell? I'm thinking maybe the problem is that it is "swallowing" the selection and you might be able to prevent that, allowing the selection to pass on to the inner cell. Just a guess - I've never tried this. – matt Mar 08 '17 at 16:27
  • I just tried it, unfortunately it didn't worked – J.Doe Mar 08 '17 at 16:34

0 Answers0