集合视图选择机制,存在吗?
Collection View Selection Mechanism, Is it exists?
嗯,我的 collectionView:didSelectItemAtIndexPath:
没有被调用。
我看了很多答案,none对我有帮助。
没有接受触摸并阻止点击的视图(我已经仔细检查)
于是我开始探索:
集合视图有 3 个 GestureRecognizers:
UIScrollViewDelayedTouchesBeganGestureRecognizer
UIScrollViewPanGestureRecognizer
_UIDragAutoScrollGestureRecognizer
如您所见,其中 none 个是 UITapGestureRecognizer
根据 docs:
The collection view calls this method when the user successfully selects an item in the collection view. It does not call this method when you programmatically set the selection.
那么,我应该自己添加一个 TapGesture 识别器吗?并调用委托方法?我不这么认为。 Apple 做了一些事情,但有些事情不起作用!
好吧,我已经弄明白了,我相信它会对其他人有所帮助。感谢所有试图提供帮助的人 - 你提供帮助是因为我认为这行不通,你给了我继续尝试的理由 =]
好吧,我有以下层次结构:
View
|
+----CollectionView
|
+----CollectionViewCell
|
+----TextView
TextView
填满了整个单元格。
问题是 TextView
阻止 每次点击而不是将其转发到单元格!
但它 确实 转发其他触摸(如 Pan)
The solution is:
cell.textView.isUserInteractionEnabled = false
嗯,我的 collectionView:didSelectItemAtIndexPath:
没有被调用。
我看了很多答案,none对我有帮助。
没有接受触摸并阻止点击的视图(我已经仔细检查)
于是我开始探索:
集合视图有 3 个 GestureRecognizers:
UIScrollViewDelayedTouchesBeganGestureRecognizer
UIScrollViewPanGestureRecognizer
_UIDragAutoScrollGestureRecognizer
如您所见,其中 none 个是 UITapGestureRecognizer
根据 docs:
The collection view calls this method when the user successfully selects an item in the collection view. It does not call this method when you programmatically set the selection.
那么,我应该自己添加一个 TapGesture 识别器吗?并调用委托方法?我不这么认为。 Apple 做了一些事情,但有些事情不起作用!
好吧,我已经弄明白了,我相信它会对其他人有所帮助。感谢所有试图提供帮助的人 - 你提供帮助是因为我认为这行不通,你给了我继续尝试的理由 =]
好吧,我有以下层次结构:
View
|
+----CollectionView
|
+----CollectionViewCell
|
+----TextView
TextView
填满了整个单元格。
问题是 TextView
阻止 每次点击而不是将其转发到单元格!
但它 确实 转发其他触摸(如 Pan)
The solution is:
cell.textView.isUserInteractionEnabled = false