How to expand and collapse parts of NSSplitView programmatically?

cocoafan picture cocoafan · May 29, 2009 · Viewed 16k times · Source

I want to replace RBSplitView with NSSplitView in my existing project. The application is now leopard only and I would like to replace RBSplitView with the new NSSplitView shipped with Leopard.

However, I'm missing RBSplitView's handy methods expand and collapse in NSSplitView. How can I expand and collapse parts of NSSplitView programmatically?

Answer

Andreas Järliden picture Andreas Järliden · Apr 28, 2010

Simply hide the subview you want to collapse, e.g.

[aSubViewToCollapse setHidden:YES];

You might also want to implement the delegate method -(BOOL)splitView:shouldHideDividerAtIndex: to return YES to hide the divider when a collapsed.