ios的 – 在uicollectionview的底部添加加载指标

在iOS中是否有内置的支持,在UICollectionView中添加一个“loader”(UIActivityIndi​​cator),这样每次用户滚动到最后一个数据单元时,他都会看到另一个带有加载指示符的水平子视图?

不,没有“内置”的方式。 你需要做的是有一个额外的单元格,其中包含一个加载器。 检测这个单元何时出现是相当简单的,在这一点上你可以开始调用来加载更多的数据。

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return [data count] + 1; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell; if (indexPath.item < [data count]) { cell = ...; // regular cell } else { cell = ...; // cell with loading indicator } return cell; }