【发布时间】:2013-04-19 19:34:31
【问题描述】:
假设标准配置(向上/向下),我想检测用户何时向上或向下滚动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{
【问题讨论】:
-
检查这个stackoverflow.com/questions/6217900/… 知道你已经到了谷底。
-
我已经知道如何检测我是否已触底。谢谢。
-
如果你想知道是向上(还是向下):stackoverflow.com/questions/7706152/…
标签: iphone ios ipad uicollectionview uiscrollviewdelegate