How can I set the start position of a NSSplitView?
The closest thing I've found that looks like it would work is setPosition
//Set splitView position.
[splitView setPosition:330 ofDividerAtIndex:0];
This doesn't seem to do anything though, my splitview still starts with the divider in the center.
ANy ideas?
You don't set the position of the divider, you set the sizes of your NSSplitView's subviews. The divider is then repositioned automatically.
This is how I positioned my divider and subview size (in swift):
let subview: NSView = mySplitView.subviews[1] as NSView
subview.setFrameSize(NSMakeSize(subview.frame.size.width, 100))
NSSplitView
needs initial non-sized bounds to make them layout correctly.
If your view has zero-size, then it will not show expected layout.
The best way is providing non-zero layout (this is what IB does), but sometimes this is impossible.
If you cannot provide non-zero size, then I think you have to provide proper - (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
delegate method implementation to layout everything manually yourself. (this is my current best practice)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With