UICollectionView 只在用户双击时调用 didSelectItemAtIndexPath,当用户单击时不会调用 [英] UICollectionView only calling didSelectItemAtIndexPath if user double taps, will not call when user single taps

查看:55
本文介绍了UICollectionView 只在用户双击时调用 didSelectItemAtIndexPath,当用户单击时不会调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UICollectionView,它与屏幕的大小差不多.它显示的 UICollectionViewCell 与 collectionView 的大小相同.每个单元格都有一个 UIImage,它是单元格的大小.CollectionView 启用了分页,因此本质上它是用户可以滑动的全屏照片幻灯片.

I have a UICollectionView which is about the size of the screen. The UICollectionViewCells that it displays are the same size as the collectionView. Each cell has a UIImage which is the size of the cell. The CollectionView has paging enabled so essentially it is a full screen photo slideshow that the user can swipe through.

问题在于
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 仅在用户用两根手指点击单元格或用一根手指长按然后释放时才会被调用.它似乎没有单击选择的默认行为.我没有对 CollectionView 手势识别器进行任何更改,因此无法找到解决此问题的方法.

The problem is that
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath is only being called if the user taps with two fingers on a cell or long presses with one finger and then releases. It does not seem to have the default behaviour of single tap selection. I have not made any changes to the CollectionView gesture recognizer so am having trouble finding a solution to this problem.

推荐答案

你确定你没有不小心覆盖了 - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath?选择"与取消选择"过去曾让我因 Xcode 的代码补全而陷入困境.

Are you sure you're not accidentally overriding - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath? "Select" vs. "deselect" has tripped me up in the past with Xcode's code completion.

这篇关于UICollectionView 只在用户双击时调用 didSelectItemAtIndexPath,当用户单击时不会调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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