I am building a Pinterest like app, which has a uicollectionview with endless cells, each having an image.
Now continually scrolling through the collectionview, more images are loaded and cached.
I am observing that the memory usage is reaching 200MB and increasing.
My question is what are the best practices used in this case ?
One important thing is to reuse your cell. You can reference to the following method.
func dequeueReusableCell(withReuseIdentifier identifier: String,
for indexPath: IndexPath) -> UICollectionViewCell
https://developer.apple.com/documentation/uikit/uicollectionview/1618063-dequeuereusablecell
Call this method from your data source object when asked to provide a new cell for the collection view. This method dequeues an existing cell if one is available or creates a new one based on the class or nib file you previously registered.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.