带有 UIScrollView 的 UICollectionViewCell 取消了 didSelectItemAtIndexPath [英] UICollectionViewCell with UIScrollView cancels didSelectItemAtIndexPath

查看:26
本文介绍了带有 UIScrollView 的 UICollectionViewCell 取消了 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 UIScrollViewcancels 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆