Great answer from @tounaobun. Tested and works as expected:
1) If you click anywhere in the collection that is not an item, then the table cell below it will select only a penalty.
2) if you click on the elements in the collection view, then the table cell will not be selected, and you can interact normally with the collection view (for example, scrolling, calling didSelectItem, etc.)
I turned to quick for reference:
Swift 3:
class TableCellCollectionView: UICollectionView { override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { if let hitView = super.hitTest(point, with: event) { if hitView is TableCellCollectionView { return nil } else { return hitView } } else { return nil } }
Just add this class definition to your code (I have it in the utility file), and then change the collection view class from UICollectionView to TableCellCollectionView, and you should be set up.
William T.
source share