按单元格而不是屏幕分页UICollectionView [英] Paging UICollectionView by cells, not screen
问题描述
我有 UICollectionView
水平滚动,并且每个屏幕总共有2个单元并排。我需要在一个单元格的开头停止滚动。启用分页后,集合视图会滚动整个页面,一次是2个单元格,然后停止。
I have UICollectionView
with horizontal scrolling and there are always 2 cells side-by-side per the entire screen. I need the scrolling to stop at the begining of a cell. With paging enabled, the collection view scrolls the whole page, which is 2 cells at once, and then it stops.
我需要启用单个单元格的滚动,或者在单元格的边缘停止滚动多个单元格。
I need to enable scrolling by a single cell, or scrolling by multiple cells with stopping at the edge of the cell.
我试图继承 UICollectionViewFlowLayout
并实现方法 targetContentOffsetForProposedContentOffset
,但到目前为止我只能破坏我的集合视图并停止滚动。有没有更简单的方法来实现这个以及如何,或者我真的需要实现 UICollectionViewFlowLayout
子类的所有方法?谢谢。
I tried to subclass UICollectionViewFlowLayout
and to implement the method targetContentOffsetForProposedContentOffset
, but so far I was only able to break my collection view and it stopped scrolling. Is there any easier way to achieve this and how, or do I really need to implement all methods of UICollectionViewFlowLayout
subclass? Thanks.
推荐答案
好的,所以我在这里找到了解决方案: targetContentOffsetForProposedContentOffset:withScrollingVelocity without subclassing UICollectionViewFlowLayout
OK, so I found the solution here: targetContentOffsetForProposedContentOffset:withScrollingVelocity without subclassing UICollectionViewFlowLayout
我应该搜索 targetContentOffsetForProposedContentOffset
在开头。
这篇关于按单元格而不是屏幕分页UICollectionView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!