Trouble With NSSplitView Starting Sizes (Storyboards and Swift)

人走茶凉 提交于 2019-11-29 09:43:34

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27664044/trouble-with-nssplitview-starting-sizes-storyboards-and-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!