Hello Cocoa List,

I’m in the process of porting a hobby project to up-to-date Swift so it can be 
used on Catalina (and I can upgrade my work machine - still looking for a 
QuickTime 7 Pro replacement, though).  I’ve encountered a phenomenon 
subclassing NSCollectionViewFlowLayout that I haven’t been able to resolve.

I have a Core Data backed NSArrayController feeding data to a NSCollectionView 
(still using XIBs, as that made the porting easier). That all works fine, 
although was surprisingly tricky to get going.  I implemented a 
NSCollectionViewFlowLayout subclass to provide a left justified layout. I then 
implemented the NSCollectionViewDelegateFlowLayout function sizeForItemAt: to 
provide custom sizes for my items.  This all works as intended during testing 
when the collection view is first loaded.  However, if I resize the enclosing 
window, all the items reduce in size to what appears to be a single pixel and I 
can’t work out where the tiny size is coming from. My output of sizeForItemAt 
always seems to have sensible values, and I can’t see an obvious place for 
where else the collection view would be getting sizes from.

I’m only implementing an init function, to set the estimatedItemSize, 
sectionInset and spacing values, and then overriding 
layoutAttributesForElements, as that seems to be all that’s required for my use 
case. I do not have any headers or footers or sections in my scenario, so the 
Array Controller is pretty simple too, although it acts as the Data Source and 
Delegate for the Collection View.

Can anyone give me pointers for what I am screwing up? My web searches for this 
only return a meagre set of results which don’t help much.

Kind regards,
Arved
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to