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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With