ios-在uicollectionview的底部添加加载指示器 [英] ios - add loading indicator at the bottom of uicollectionview

查看:441
本文介绍了ios-在uicollectionview的底部添加加载指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有内置支持将加载程序"(UIActivityIndi​​cator)添加到uicollectionview,这样,每次用户滚动到最后一个数据单元时,他都会看到带有加载指示器的另一个水平子视图吗?

in iOS is there any built in support for adding a "loader" (UIActivityIndicator) to a uicollectionview, such that every time a user scroll to the last cell of data he'll see another horizontal subview with the loading indicator?

推荐答案

不,没有内置"方式.您需要做的是增加一个包含加载程序的单元格.检测何时显示此单元格是很简单的,此时您可以开始调用以加载更多数据.

No, there's no "built in" way. What you'd need to do is have an extra cell that contains a loader. It's fairly trivial to detect when this cell appears, at which point you can start the call to load more data.

- (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-在uicollectionview的底部添加加载指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆