Search code examples
macosuser-interfaceautolayoutinterface-buildernstableview

Interface Builder and NSTableView top constraint


I have the following UI definition:

UI Hierarchy

I wanted to define the constraints for the components but whenever I try to add a constraint so that the Bordered Scroll View - Table View.top is topStackView.bottom + 20, I get a constraint conflict. There is a hidden constraint where the Bordered Scroll View - Table View.t must be topStackView.bottom + 8.

So, my question is where is this +8 constraint coming from? I assume it must be from the NSScrollView that contains the table as all the components inside seem to have Translate Masks Into Constraints.

How can I properly use Auto Layout so achieve what I want?


Solution

  • I haven't done much with MacOS apps, but this may solve your issue...

    Delete the Bordered Scroll View - Table View.top is topStackView.bottom + 20 that you're trying to add.

    You have them embedded in a vertical stack view - mainStackView - so set the Spacing on that stack view to 20.

    It may not look right in Storyboard / IB, but the result should be correct (I have two buttons at the top, but that won't make a difference):

    enter image description here