• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Subclassing NSCollectionViewFlowLayout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing NSCollectionViewFlowLayout


  • Subject: Subclassing NSCollectionViewFlowLayout
  • From: Arved von Brasch via Cocoa-dev <email@hidden>
  • Date: Sun, 20 Oct 2019 21:54:35 +1100

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Subclassing NSCollectionViewFlowLayout
      • From: Arved von Brasch via Cocoa-dev <email@hidden>
  • Prev by Date: Re: FYI: info on our scary Mac rebooting iOS testing crash.
  • Next by Date: Re: Not seeing rightMouseDown: - what are the docs actually saying ?
  • Previous by thread: Re: Not seeing rightMouseDown: - what are the docs actually saying ?
  • Next by thread: Re: Subclassing NSCollectionViewFlowLayout
  • Index(es):
    • Date
    • Thread