2

I want to show a NSCollectionView inside a NSTableCellView. I have it setup correctly, and it works for the most part, but the collectionView's scrollview doesn't seem to resize properly against the NSTableCellView, even though I have auto-layout constraints setup for this.

enter image description here

Is there anything I can do to setup constraints in a way that the scrollview resizes against the NSTableCellView (which should also let the collectionView also resize itself)?

EDIT:

To elaborate, what I really want to do is have the collectionView expand and resize as the window is resized, and have it take up the same width as the tableViewCell, and depending on the number of items in the collection view, resize the height of the outlineView & hence determine the height of the outlineView's row. It works fine when the collectionView is part of an ordinary view, but I can't get it to resize itself inside a NSTableCellView.

Z S
  • 7,039
  • 12
  • 53
  • 105

1 Answers1

2

Firstly, remove all of the constraints you've set for your collectionview/scrollview.

Now, you will need to make 4 constraints, one for each of the leading, trailing, top and bottom space from the scrollview to its superview. Make sure width and height are not constrained. I've done this in a recent app I've made and it worked rather well.

EDIT: Below in the comments we figured out the column wasn't resizing so the constraints were correctly set.

IronManGill
  • 7,222
  • 2
  • 31
  • 52
Alex Zielenski
  • 3,591
  • 1
  • 26
  • 44
  • Those are the same constraints, set up in IB instead of code. They are setup from the NSScrollView, which contains the collectionView (can't seem to set a constraint for the collectionView), to it's superview, which is the NSTableCellView right now. I can try doing the same in code – Z S Jul 17 '14 at 01:23
  • It should work from IB. What exactly happens when you resize the table view? – Alex Zielenski Jul 17 '14 at 01:23
  • the collection view's width doesn't change, though the other NSTableCellView (which doesn't have a collectionView inside it) resizes fine – Z S Jul 17 '14 at 01:36
  • Does the table cell view itself that owns the collection view change size? It could be that the column it is in isn't expanding. Though seems unlikely since the other cell does resize. – Alex Zielenski Jul 17 '14 at 01:39
  • Ah, it seems like the column had a maximum size of 1000! Not sure why it's set this way. I updated it to 10000 and now it resizes just fine. – Z S Jul 17 '14 at 01:52
  • I'm going to update my answer. Could you mark it off? – Alex Zielenski Jul 17 '14 at 01:53
  • Thank you so much!! I was having the exact same problem as the OP, this answer solved my issue perfectly. – Supertecnoboff May 18 '17 at 08:37