Created
October 31, 2014 02:39
-
-
Save jellybeansoup/3b5be4045628089afd0d to your computer and use it in GitHub Desktop.
batched polling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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