0

I have a few (20 - 30) images stored the app and on loading them on to a collection view, they start off small as shown in the screen shot and on scrolling they become the normal size.

Any ideas on how to fix this? Quite confused on why!

Here is my code for the cellForItemAtIndexPath:

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

        let cellSelected = iconCollectionView.dequeueReusableCellWithReuseIdentifier("IconCell", forIndexPath: indexPath) as! IconCollectionViewCell

        cellSelected.workoutImage.image = iconsArray[indexPath.item].exerciseIcon

        cellSelected.layer.shouldRasterize = true
        cellSelected.layer.rasterizationScale = UIScreen.mainScreen().scale;

        return cellSelected
    }

enter image description here

enter image description here

Gugulethu
  • 1,426
  • 3
  • 18
  • 36

1 Answers1

1
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {



    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? CollectionViewCell
    cell?.imageth.image = UIImage(named: (arrayName[indexPath.row] as? String)!)
    return cell!
Shamas S
  • 7,507
  • 10
  • 46
  • 58
anonymous
  • 26
  • 1