ios - UICollectionView not displaying cells after fast scroll -


i have uicollectionview while scroll in occasions stops updating cells. load few cells when scroll down or rest of uicollectionview empty although contensize bigger few cells visibles sizes.

it happens more when scroll fast, randomly cellforitematindexpath stops being called , uicollectionview shows last loaded cells, rest of space empty.

here code:

[self.collectionview registernib:[uinib nibwithnibname:nsstringfromclass([newscollectionviewcell class]) bundle:nil] forcellwithreuseidentifier:nsstringfromclass([newscollectionviewcell class])];  [self.collectionview registerclass:[newsheadercollectionreusableview class]  forsupplementaryviewofkind:uicollectionelementkindsectionheader withreuseidentifier:nsstringfromclass([newsheadercollectionreusableview class])]; 

pragma mark uicollectionviewdatasource

- (nsinteger)numberofsectionsincollectionview:(uicollectionview *)collectionview { return 1; }  - (nsinteger)collectionview:(uicollectionview *)collectionview  numberofitemsinsection:(nsinteger)section { return self.newsarray.count; }  - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview               cellforitematindexpath:(nsindexpath *)indexpath { newscollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:nsstringfromclass([newscollectionviewcell class]) forindexpath:indexpath];  [cell refreshwithcontentmodel:self.newsarray[indexpath.item]];  return cell; }  - (uicollectionreusableview *)collectionview:(uicollectionview *)collectionview        viewforsupplementaryelementofkind:(nsstring *)kind                              atindexpath:(nsindexpath *)indexpath { newsheadercollectionreusableview *collectionreusableview = [collectionview dequeuereusablesupplementaryviewofkind:uicollectionelementkindsectionheader withreuseidentifier:nsstringfromclass([newsheadercollectionreusableview class]) forindexpath:indexpath];  if (self.newsarray.count) {     [collectionreusableview refreshwithcontentmodel:self.newsarray[0]]; }  return collectionreusableview; } 

pragma mark uicollectionviewdelegate

- (void)collectionview:(uicollectionview *)collectionview willdisplaycell:(uicollectionviewcell *)cell foritematindexpath:(nsindexpath *)indexpath { if (indexpath.item == self.newsarray.count - 1) {     [self addmorenews]; // add items array , call collection reloaddata } } 

pragma mark uicollectionviewdelegateflowlayout

- (cgsize)collectionview:(uicollectionview *)collectionview               layout:(uicollectionviewlayout *)collectionviewlayout sizeforitematindexpath:(nsindexpath *)indexpath {     return cgsizemake(ceilf(self.collectionview.bounds.size.width / 3.0) - 10, ceilf(self.collectionview.bounds.size.height / 3.0)); }  - (cgsize)collectionview:(uicollectionview *)collectionview               layout:(uicollectionviewlayout *)collectionviewlayout referencesizeforheaderinsection:(nsinteger)section {  return cgsizemake(self.collectionview.bounds.size.width, ceilf(self.collectionview.bounds.size.height / 2.0)); } 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -