Pass UICollectionView touch event to its parent UITableViewCell

前端 未结 5 1686
温柔的废话
温柔的废话 2020-12-09 20:30

Here is the view structure:

The outer view is a UITableView.

Inside the UITableViewCell, there is a UICollectionView

5条回答
  •  自闭症患者
    2020-12-09 20:50

    You can override the point(inside:with:) method of UICollectionView and manually check whether any cell contains specified point:

    class CollectionView: UICollectionView {
        override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
            visibleCells.contains(where: { $0.frame.contains(point) })
        }
    }
    

提交回复
热议问题