带有 UIScrollView 的 UICollectionViewCell 取消了 didSelectItemAtIndexPath [英] UICollectionViewCell with UIScrollView cancels didSelectItemAtIndexPath
问题描述
我有一个 UICollectionView
可以水平滚动以一次显示一个 UICollectionViewCell
.每个 UICollectionViewCell
都有一个垂直滚动的 UIScrollView
作为子视图,用于滚动单元格的内容.UIScrollView
只覆盖了 UICollectionViewCell
内部的 90% 左右 - 即单元格的外框没有被它覆盖.p>
原来被UIScrollView
覆盖的UICollectionViewCell
部分取消了UICollectionView
委托didSelectItemAtIndexPath
.因此,当在 UIScrollView
内发生简单的点击时,此方法不会 被调用,而如果点击发生在单元格的外部,即 UIScrollView
,这个方法被调用了.
关于如何实现即使在 UIScrollView
内点击也可以调用 didSelectItemAtIndexPath
方法的设置的任何建议?
点击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屋!