Skip to content

Instantly share code, notes, and snippets.

@jellybeansoup
Created October 31, 2014 02:39
Show Gist options
  • Select an option

  • Save jellybeansoup/3b5be4045628089afd0d to your computer and use it in GitHub Desktop.

Select an option

Save jellybeansoup/3b5be4045628089afd0d to your computer and use it in GitHub Desktop.

Revisions

  1. jellybeansoup created this gist Oct 31, 2014.
    26 changes: 26 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #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;
    }