Skip to content

Instantly share code, notes, and snippets.

@jellybeansoup
Created October 31, 2014 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jellybeansoup/3b5be4045628089afd0d to your computer and use it in GitHub Desktop.
Save jellybeansoup/3b5be4045628089afd0d to your computer and use it in GitHub Desktop.
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