I have a UICollectionView that contains images as elements in my data store.
I want to load a high resolution image into an element only when its corresponding UICollectionViewCell is currently displayed on the screen. Later, when the UICollectionViewCell disabled, I want to return the UIImage element to the low resolution version.
My question is: how can I detect when a UICollectionViewCell comes out of the screen?
(I tried to use the prepareForReuse method, but I cannot predict when it will be called).
I am currently using a piece of code that is in scrollViewDidScroll , and each time the view scrolls, I check self.collectionView.visibleCells to see which cells scroll from the screen.
It seems like a bit of overhead, and I wonder if there is a method called UICollectionViewCell itself when it scrolls on the screen?
ios uicollectionview uicollectionviewcell uicollectionreusableview
Boaz saragossi
source share