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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;
}