Pass UICollectionView touch event to its parent UITableViewCell

前端 未结 5 1695
温柔的废话
温柔的废话 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:55

    Code from highest voted answer can be easily shortened.

    Swift 4.1:

    final class InteractiveCollectionView: UICollectionView {
        override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
            return super.hitTest(point, with: event) as? InteractiveCollectionView
        }
    }
    

提交回复
热议问题