ios - How to add Load more cell in UICollectionView? -
i want add load more cell in uicollectionview ? can tell me how can add load button ? have created collectionview works fine want add load more button in bottom of collection view cell this
here's collection view
#pragma mark <uicollectionviewdatasource> - (nsinteger)numberofsectionsincollectionview:(uicollectionview *)collectionview { return 3; } - (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { switch (section) { case 0: return 66; case 1: return 123; } return 31; } - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { nsuinteger row = [indexpath row]; nsuinteger count = [self.stockimages count]; if (row == count) { //add load more cell } democellview *cell = [collectionview dequeuereusablecellwithreuseidentifier:[democellview reuseidentifier] forindexpath:indexpath]; // configure cell cell.titlelabel.text = [nsstring stringwithformat:@"%ld", (long)indexpath.item + 1]; nslog(@"%@", self.stockimages[indexpath.item % self.stockimages.count]); cell.imageview.image = self.stockimages[indexpath.item % self.stockimages.count]; return cell; } #pragma mark <demolayoutdelegate> - (void) collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath *)indexpath { // // insert new cell after clicking load more data } - (cgfloat)collectionview:(uicollectionview *)collectionview layout: (uicollectionviewlayout *)collectionviewlayout heightforheaderinsection:(nsinteger)section { return kfmheaderfooterheight; } - (cgfloat)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout *)collectionviewlayout heightforfooterinsection:(nsinteger)section { return kfmheaderfooterheight; }
you can add footer
- (uicollectionreusableview *)collectionview:(jsqmessagescollectionview *)collectionview viewforsupplementaryelementofkind:(nsstring *)kind atindexpath:(nsindexpath *)indexpath { if ([kind isequaltostring:uicollectionelementkindsectionfooter]) { //load footer have registered earlier load more [super dequeuereusablesupplementaryviewofkind:uicollectionelementkindsectionfooter withreuseidentifier:@“load more footer” forindexpath:indexpath]; } return nil; }
Comments
Post a Comment