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:
- sorting data source same order
- saving cells in custom dictionary, , rematch data cells
self.collectionview!.reloaditemsatindexpaths(indexpaths)indexpaths contain current paths- 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
Post a Comment