NSCollectionView / NSCollectionViewFlowLayout

I'm trying to create a vertical collection view Flow layout whose items size automatically with a single column. I've read the AppKit release notes, the updated documentation, and the headers for the various classes. I've watched the 2015 WWDC videos (NSCollectionView and AutoLayout Mysteries 1 & 2). The NSCollectionViewItem subclass represents an auto-layout-compiant, self-vertically-sizing text view (that, incidentally, auto-sizes great in a stack view, even during editing, so it's not an auto-layout issue as far as I can tell).


I've verified the collection view items are my custom subclass and I can see they're loaded with the correct information (text/image) but their self-sizing is ignored. I first tried setting the collection view's collectionViewLayout property to an instance of NSCollectionViewFlowLayout that I had configured with a non-zero estimatedItemSize (which the headers say should allow for cells that self-size via preferredLayoutAttributesFittingAttributes, which can be overridden in the collection view item subclass, but I'm not sure what to do with it).


At this point, I'm completely stuck. Any guidance would be appreciated.


Note: I'm only pursuing this because, after getting my hopes up with the auto-sizing table cell height comment (that turned out only to apply to UITableView), I'm trying to find an "easy" way around for OS X.

(I'm beginning to suspect this part of the API isn't quite done baking yet.)

I am stuck as well.


If you dig deeper, there are some methods you can use to provide the information about the size, such as collectionView(collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> NSSize, but they are never ever called.


I agree with you: this has yet to be properly finished. And it is quite frustrating, because my collections show perfectly, but stacked one over the other. And they do not obey to any AutoLayout or selection changes. ****.


Any ideas, anyone? 🙂

collectionView(collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> NSSize is called in my case.


It works by setting the delegate to the corresponding view controller, with both NSCollectionViewDelegate and NSCollectionViewDelegateFlowLayout protocol implemented. The mentioned method in fact comes from NSCollectionViewDelegateFlowLayout

NSCollectionView / NSCollectionViewFlowLayout
 
 
Q