0

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

Mark
  • 16,906
  • 20
  • 84
  • 117
  • You can simply mimic the behavior. Create a new project, make it document-based with storyboard. Remove the default NSViewController in Storyboard and replace it with a NSSplitViewController. Link the NSSplitViewcontroller to the contentViewController of the NSWindowViewController. Run your app nothing appears to be wrong. Now open a new document (CMD&N) it only has the title bar. – Mark Sep 17 '16 at 17:39
  • I already deleted the comments since I did exactly that :)) – Julian F. Weinert Sep 17 '16 at 17:48
  • I still think you're missing layout constraints. I'd add a n answer, but that sounds too obvious... – Julian F. Weinert Sep 17 '16 at 17:48
  • Yea so in order to fix this issue I would need to add a custom view to the top and bottom view controllers and add minimum constraints am I right? – Mark Sep 17 '16 at 17:53
  • Let me answer... ;-) – Julian F. Weinert Sep 17 '16 at 17:54

1 Answers1

0

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

Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107