ios - UICollectionView loads async image in different cells due to reload during async image downloading -
when loading uicollectionview
cells call method downloads image async.
during download however, collection view reloaded , when async image downloaded set in 2 different cells.
i have tried using nsoperationqueue
in dealloc
call cancelalloperations:
, didn't work.
what best way cancel download , can provide sample code?
thanks.
i think best practice launch requests lazily need images, cache results, , have no expectations state of collection when request completes.
reloading collection not invalidating event request image in cell. scrolling away is, user might scroll back. make request, , in completion block request cache result , reloaditemsatindexpaths: on index path associated request.
my answer here, provides working code.
Comments
Post a Comment