von*_*dip 7 ios uicollectionview
在iOS中是否有内置支持将"加载器"(UIActivityIndicator)添加到uicollectionview,这样每次用户滚动到最后一个数据单元时,他会看到另一个带有加载指示符的水平子视图?
不,没有"内置"的方式.你需要做的是有一个包含加载器的额外单元格.检测此单元格何时出现是相当简单的,此时您可以启动调用以加载更多数据.
- (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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5795 次 |
| 最近记录: |