Search code examples
macosnssplitviewcontroller

How can I fix it so that when I add a NSSplitViewController to the storyboard my window isn't collapsed?


When I add a NSSplitViewController to my document-based storyboard like so:

enter image description here

It will not respect my minimum content size and collapses instantly. Why is it doing this, is this a bug? And how do I fix it?

enter image description here


Solution

  • You need to add the proper constraints to the content of the individual splits. When you don't fill up all the space, you simply add a bottom constraint with >=.

    When I add all constraints corresponding to the screenshot below, I get the correct widow size.

    EDIT Sorry, but I definitely didn't copy you're design properly ;-)

    EDIT II

    I'll add some explanation at this point. With auto layout almost all views determine their size by the content within them. They try to be as narrow as possible, in any axis.

    That means if there is no constraint to the views bottom, it will not know about any contents height and thus returns zero for its height.

    layout constraints architecture resulting window appearance