For the future, it is better to post the relevant code here rather than post an image of all the code.
You can start off with changing the cellForItemAtIndexPath
implementation. You are downloading the image in the method (as a synchronous implementation). So unless the image is downloaded by contentsOfURL:
and rendered, the cell won’t display. And the image is being downloaded every time the cell renders.
A better alternative is to download images in a separate thread, keep them for later use (and avoid downloading every time) and update the cell when the image is available. You can use an existing implementation like SDWebImage to make things easier for you.
1
solved Why does my App lags when scrolling UICollectionView (Swift)? [closed]