在UICollectionView中显示上一个/下一个单元格的预览时,如何减慢滚动速度?

我知道这个问题已经有很多问题了。 但是大部分问题已经过时或者没有答案。 我的执行问题不是预览,但其分页速度?

我可以在UICollectionView显示前一个/下一个单元格,但是当我尝试快速滚动时,它将滚动(跳过)1或2页。 当我以很快的速度滚动时,会发生这种情况。

对于笔记,我正在使用自定义布局。

这是我的代码:

 - (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity { CGRect cvBounds = self.collectionView.bounds; CGFloat halfWidth = cvBounds.size.width * 0.5f; CGFloat proposedContentOffsetCenterX = proposedContentOffset.x + halfWidth; NSArray* attributesArray = [self layoutAttributesForElementsInRect:cvBounds]; UICollectionViewLayoutAttributes* candidateAttributes; for (UICollectionViewLayoutAttributes* attributes in attributesArray) { // == Skip comparison with non-cell items (headers and footers) == // if (attributes.representedElementCategory != UICollectionElementCategoryCell) { continue; } // == First time in the loop == // if(!candidateAttributes) { candidateAttributes = attributes; continue; } if (fabsf(attributes.center.x - proposedContentOffsetCenterX) < fabsf(candidateAttributes.center.x - proposedContentOffsetCenterX)) { candidateAttributes = attributes; } } return CGPointMake(round(candidateAttributes.center.x - halfWidth), proposedContentOffset.y); } 

任何帮助将不胜感激。