-1

Here's my problem. I have a UICollectionViewCell having an image View. The image is downloaded from a link. The images are of different sizes and I want the collectionView cell size to change with the image size. I am currently accomplishing this by forcing the layout inside

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath)

by placing this line of code in it

collectionViewTrending.reloadItemsAtIndexPaths([indexPath])

The below UICollectionViewDelegate function

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) 

is handling the resizing of the cell. Though this is working but it definitely is NOT efficient. It is inefficient because scrolling on the collectionView is taking longer and it is not smooth. Is there any way in which I can resize the cell without degrading the performance?

MrDank
  • 2,020
  • 2
  • 17
  • 39
  • `but it definitely is NOT efficient.` In what way? What is inefficient? What are your performance requirements and what have you measured the current performance at? – nhgrif Apr 24 '16 at 17:39
  • I haven't measured it. I have tested it on my phone and I see that scrolling down collectionView is taking longer and is not smooth. From the perspective of a user, this is pretty irksome. – MrDank Apr 24 '16 at 17:41
  • You need to [edit your question](http://stackoverflow.com/posts/36826638/edit) and update it to include a description of the behavior that is problematic, as well as the actual code that is causing this behavior (which requires measuring). – nhgrif Apr 24 '16 at 17:42

1 Answers1

0

Remove that line--collectionViewTrending.reloadItemsAtIndexPaths([indexPath]) first.. Then set sizeForItem method of collectionView properly..It will work fine..

Punit
  • 1,330
  • 6
  • 13