如果用户双击,UICollectionView只调用didSelectItemAtIndexPath,当用户单击时不会调用 [英] UICollectionView only calling didSelectItemAtIndexPath if user double taps, will not call when user single taps
问题描述
我有一个大小与屏幕大小相同的UICollectionView。它显示的UICollectionViewCells与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
? X谱代码完成后,选择与取消选择让我绊倒了。
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屋!