ios - UICollectionView and UITableView reload causes reorder of cells -


i have situation thread got new models server, , try reload cells in uicollectionviewcontroller.

i call collectionview.reloaddata() (on main thread) , cells changing positions(meaning, can see content of cells changing position 1 cell another)

none of following works:

  1. sorting data source same order
  2. saving cells in custom dictionary, , rematch data cells
  3. self.collectionview!.reloaditemsatindexpaths(indexpaths) indexpaths contain current paths
  4. reloading visiable cells self.collectionview!.visiblecells()

what missing here?

if server returned right ordered data,i'm afraid didn't clean data in cells.you should set imageview.image nil when hadn't loaded image data or there no image in data. if customized cell in uitableviewdatasource,you should this:

if(data.image != nil) {     imageview.image = data.image; } else {     imageview.image = nil; } 

if did in custom table view cell class,do this:

-(void)prepareforreuse {     imageview.image = nil  } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -