2

I'm trying to add a subview to my NSSplitView, so that my vertical split view goes from

---------

view A (height = 100)

---------

to

----------

view A (height = 50)
----------
view B (height = 50)

----------

I thought this would be straightforward, but neither view's heights are changing after adding a new subview to the split view.

Here's what I am doing to add view B as a subview:

splitView?.addSubview(NSView(frame: NSRect(x: 0, y: 0, width: 150, height: 100)))
splitView?.adjustSubviews()

This causes splitViewDidResizeSubviews to be called, but both view heights remain at 100 and overlap each other with no divider shown.

I uploaded a sample project showing the issue: https://duke.box.com/s/f50y2pjjbf3ib0y60c7yr5h3p3nicok7

Thanks for your help

davis
  • 1,911
  • 6
  • 26
  • 50

1 Answers1

6

Ugh, so there's a checkbox in IB for the NSSplitView called 'Arranges All Subviews' which was introduced in OS X 10.11. After checking this my views are sizing correctly.

OS X 10.11 also introduced the addArrangedSubview and insertArrangedSubview:atIndex methods

Extremely annoying since this doesn't even seem to be listed in the NSSplitView docs.

davis
  • 1,911
  • 6
  • 26
  • 50