Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble With NSSplitView Starting Sizes (Storyboards and Swift)

I just started a simple Cocoa app using Swift, Storyboards, and a Document.

The only change I've made is to replace the default View Controller in Main.storyboard with a Split View Controller. Everything works great as far as the subviews populating correctly except for one thing: the divider is always at the far left of the window when I start the app. This is with a vertical Split View. (If I change to horizontal the divider starts at the very top.)

I have tried adding constraints but IB won't even allow me to add constraints to anything except content within the subviews.

I've also tried using splitView.setPosition ofDividerAtIndex but had no success.

How can I specify either the width of the left subview or the position of the divider?

like image 870
Jspies Avatar asked Dec 27 '14 03:12

Jspies


1 Answers

The initial size of the split view is based on the constraints. If there are no constraints to satisfy then the width or height is 0. You are correct, you can't add any constraints to the root view. You have to add subviews that have constraints that imply the desired height or width.

This could simply be a NSView with a set width or height constraint.

like image 64
Cory Avatar answered Sep 18 '22 16:09

Cory