0

I have an NSCollectionView, which items are dynamically sized.

When the item is returned by [collectionView makeItemWithIdentifier:reuseIdentifier forIndexPath:indexPath] its view has the desired size

BUT

the subviews are not yet sized accordingly, they still have the xib sizes.

The problem is that while setting the properties of the item, I need to know the final size of all subviews (because I am optimizing some images).

How can I force the subviews to be resized just after getting the item from makeItemWithIdentifier:forIndexPath: ?

Or maybe, how can I know their future size ?

Or any other solution ?

AirXygène
  • 2,409
  • 15
  • 34

1 Answers1

0

I finally ended up starting the optimized image computation not at the moment the item is created with makeItemWithIdentifier:reuseIdentifier forIndexPath:indexPath:, because I did not find a way to know the final size.

I start the image optimized image computation at the first drawRect: call.

During this call I quickly draw a non-optimized image, and start the optimized image computation in a background thread. When this completes, I send a setNeedsDisplay:YES message to the view, and the optimized image is then shown.

AirXygène
  • 2,409
  • 15
  • 34