带有 UIScrollView 的 UICollectionViewCell 取消 didSelectItemAtIndexPath [英] UICollectionViewCell with UIScrollView cancels didSelectItemAtIndexPath
问题描述
我有一个 UICollectionView
水平滚动以一次显示一个 UICollectionViewCell
.每个 UICollectionViewCell
都有一个垂直滚动的 UIScrollView
作为用于滚动单元格内容的子视图.UIScrollView
只覆盖了 UICollectionViewCell
内部的 90% 左右 - 即单元格的外框没有被它覆盖.>
结果是UIScrollView
覆盖的UICollectionViewCell
部分取消了UICollectionView
委托didSelectItemAtIndexPath
.因此,当在 UIScrollView
内发生简单的点击时,此方法不会被调用,而如果点击发生在单元格的外部,即在 UIScrollView
,这个方法被调用.
关于如何实现可以调用 didSelectItemAtIndexPath
方法的设置的任何建议,即使点击发生在 UIScrollView
中?
UIScrollView
上的点击用于查看是否应该进行滚动.
您应该抓住 UIScrollView 本身的单击 并传递它到周围的 UICollectionViewCell
.
I have a UICollectionView
that horizontally scrolls to show one UICollectionViewCell
at a time. Each UICollectionViewCell
the has a vertically scrolling UIScrollView
as subview for scrolling the contents of the cell. It is only 90 % or so of the inner part of the UICollectionViewCell
that is covered by the UIScrollView
- i.e. the outer frame of the cell is not covered by this.
It turns out that the part of the UICollectionViewCell
that is covered by the UIScrollView
cancels the UICollectionView
delegate didSelectItemAtIndexPath
. Thus when a simple tap happens within the UIScrollView
this method is not invoked, whereas if the tap happens on the outer part of the cell, i.e. outside the UIScrollView
, this method is invoked.
Any suggestions as to how to achieve a setup where it is possible to invoke the didSelectItemAtIndexPath
method even when the tap happens within the UIScrollView
?
The tap on the UIScrollView
is used to see whether scrolling should be done.
You should catch the single tap on the UIScrollView itself and pass it on to the surrounding UICollectionViewCell
.
这篇关于带有 UIScrollView 的 UICollectionViewCell 取消 didSelectItemAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!