ios - 如何通过 UICollectionView 捕捉手势?

标签 ios iphone uicollectionview uigesturerecognizer uipangesturerecognizer

我有一个 UICollectionView 和一个自定义的 UICollectionViewCell

我希望能够将 UICollectionView 手势捕捉为 UIGestureRecognizerDelegate,实际上我想通过使用此委托(delegate)的方法来处理一些手势冲突:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer

如何捕获 UICollectionViewUIGestureRecognizerDelegate

最佳答案

UICollectionView 会监听点击,但不会使用 UIGestureRecognizer

但是您可以为您感兴趣的类型(例如 UITapGestureRecognizer)添加您自己的 UIGestureRecognizerUICollectionView,设置委托(delegate)在上面和 gestureRecognizerShouldBegin: 中返回 YES 或 NO,具体取决于您是否希望 UICollectionView 执行此操作,即返回 NO 将取消您的手势并允许 Collection View 处理触摸。

如果您只想让手势优先于 Collection View 触摸处理,则将 delayTouchesBegan 设置为 YES。

更多信息在这里Collection View Programming Guide

关于ios - 如何通过 UICollectionView 捕捉手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28578946/

相关文章:

ios - 如何安装 Titanium 模块

ios - 在 isEqual 中测试 NSNumber 是否为 nil

android - Google Analytics(分析)人口统计功能是否适用于移动设备?

ios - 文件是为存档构建的,不是被链接的体系结构 (i386)

ios - 无法在异常时显示 UIAlert

iphone - iPhone 上的斜体、粗体和下划线字体

ios - 具有动态单元格内容的 UICollectionView - 让单元格记住状态

ios - 使 UICollectionView 连续滚动

iphone - NSMutableArray removeObjectAtIndex

ios - 如何在 UICollectionViewDataSource 和 UICollectionViewDelegateFlowLayout 方法中调用正确的数据源?