UICollectionView didSelectItemAtIndexPath not called when tapped on UITextView

前端 未结 6 1617
傲寒
傲寒 2021-02-13 05:13

I have a UICollectionView with custom cells- They have a UITextView that mostly covers the entire cell. This presents a problem when using didSel

6条回答
  •  不要未来只要你来
    2021-02-13 06:08

    didSelectItemAtIndexPath is called when none of the subView of collectionViewCell respond to that touch. As the textView respond to those touches, so it won't forward those touches to its superView, so collectionView won't get it.

    override hitTest:withEvent method of your collectionViewCell or CollectionView subclass and always return self from them.so it explicitly makes collectionView as first responder.

提交回复
热议问题