假设使用标准配置(向上/向下),我想检测用户何时滚动他们的
如果我知道用户正在滚动的方向,那么我可以使用这些
// 如果向下滚动,则出现节段
UIColletionView
,以及滚动方向(它是UIScrollView
的子类并符合UIScrollViewDelegate
)。我没有看到任何直接检测这一点的委托信息,尽管我可能会忽略一些东西。如果我知道用户正在滚动的方向,那么我可以使用这些
UICollectionViewDatasource
方法来确定是否应该从REST服务器加载更多数据,或清除已经拥有的信息以管理固定内存空间。// 如果向下滚动,则出现节段
- (UICollectionReusableView *)collectionView:(UICollectionView *)cv viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
// 如果往下滚动,部分中的最后一个单元格会消失
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
// 如果向上滚动,该分组中的最后一个单元格将出现
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// 如果向上滚动,则该部分正在消失
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(UICollectionReusableView *)view forElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath{