3

I have an NSSplitView with four subviews. Each subview has a header with some text and an on/off checkbox, and below it an NSTableView. The user can toggle visibility of the table by using the checkbox.

If the table is visible at program start, and the user deselects the checkbox, the table disappears. The subview thus becomes a lot smaller.

How do I make my NSSplitView react to this (by adjusting the dividers)?

Carelinkz
  • 936
  • 8
  • 27

1 Answers1

7

To programmatically set the position of a divider, invoke -setPosition:ofDividerAtIndex: on your NSSplitView.

jatoben
  • 3,079
  • 15
  • 12
  • I figured that one out, but perhaps my question needs clarification. Aside from moving the dividers around, I want to change the bounds of the subview. So: users makes the table collapse -> **bounds of subview change accordingly** -> nssplitview is notified to redistribute the dividers. I cannot figure out how to properly make the subview change size when its contents reduce (i.c., the table disappears). – Carelinkz Mar 26 '13 at 14:50
  • Have you tried just invoking `-setBounds:` on your subview? You can set it to any size you want using that method. You may also be able to get autolayout to do what you want by using `-setNeedsUpdateConstraints:`, but you will probably have to remove the table from your subview for that -- constraints still apply even if a view is hidden. – jatoben Mar 26 '13 at 17:42