Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
batched polling
#pragma mark - View life cycle
- (void)viewDidLoad {
[super viewDidLoad];
[_collectionView registerClass:[JSMRefreshViewCell class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"SearchViewRefresh"];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
// If we have more results to fetch
if( _resultsCount > _results.count ) {
return CGSizeMake( collectionView.frame.size.width, 60 );
}
// Otherwise, return zero size
return CGSizeZero;
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
// Ask for more results
[self moreSearch];
// Return the cell
JSMRefreshViewCell *view = (JSMRefreshViewCell *)[collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"SearchViewRefresh" forIndexPath:indexPath];
return view;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment