1

I want to change the layout of the NSCollectionView programmatically with 3 buttons, each button will change the layout of the collection view - 2, 3, 4 columns per row. And the NSCollectionViewItem size has to be auto-resized.

I tried searching all day, but found nothing helpful. Any help would be appreciated.

Thanks

Jun
  • 3,422
  • 3
  • 28
  • 58
  • Perhaps have a look at this [answer](http://stackoverflow.com/a/22074260/1091402) and see if you can tweak it to support multiple columns? – Rick Nov 07 '14 at 07:50
  • I actually coincidentally have been trying to do something very similar. Currently what I'm doing to get it to work is in the awakefromnib of the superview(`NSCollectionView` in your case), I check the sizes of the subviews(`NSButton` in your case), and add those sizes together and resize the superview with the new frame. I am aware this is a horrible lazy solution but I'm hoping to get my alternative solution of using auto-layout to work. I have tried programmatically setting constraints on the superview to resize it depending on the subviews, but it didn't work :\ I am following this now – A O Nov 07 '14 at 18:16

1 Answers1

0

I couldn't satisfy with Apple's stock NSCollectionView. Fortunately, Jonathan made a nice custom collection view called JNWCollectionView for cocoa which has very similar mechanics with UICollectionView on iOS.

Jun
  • 3,422
  • 3
  • 28
  • 58