ios – 在uicollectionview底部添加加载指示符

前端之家收集整理的这篇文章主要介绍了ios – 在uicollectionview底部添加加载指示符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在iOS中是否有内置支持将“加载器”(UIActivityIndi​​cator)添加到uicollectionview,这样每次用户滚动到最后一个数据单元时,他会看到另一个带有加载指示符的水平子视图?

解决方法

不,没有“内置”的方式.您需要做的是有一个包含加载器的额外单元格.检测此单元格何时出现非常简单,此时您可以启动调用以加载更多数据. @H_502_6@- (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; }

猜你在找的iOS相关文章