在UITextView上点击时,UICollectionView didSelectItemAtIndexPath未被调用 [英] UICollectionView didSelectItemAtIndexPath not called when tapped on UITextView
问题描述
我有一个带有自定义单元格的 UICollectionView
- 它们有一个 UITextView
,它主要覆盖整个单元格。使用 didSelectItemAtIndexPath
时出现问题。触发它的唯一方法是在 UITextView
之外点击。我想让它在你点击的单元格中触发,无论是否有文本视图。怎么办呢?
I have a UICollectionView
with custom cells- They have a UITextView
that mostly covers the entire cell. This presents a problem when using didSelectItemAtIndexPath
. The only way to trigger it is by tapping outside the UITextView
. I want it to trigger wherever in the cell you tap, whether there is a text view or not. How can this be done?
推荐答案
我建议使用 UIGestureRecognizer
对于每个单元格以及它被录制以将其发送到 UITextView
或者其他什么,也许可能有更好的解决方案,但我会因为简单原因而使用这个。
I would suggest to use UIGestureRecognizer
for each cell and when it taped to send it to UITextView
or whatever , perhaps there maybe a better solutions , but I would use this 1 because of simplicity reasons.
这篇关于在UITextView上点击时,UICollectionView didSelectItemAtIndexPath未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!