8

I used to use and love RBSplitView, however I failed at reimplementing it programmatically as a certain version of xcode does not support IB plugins anymore.

Therefore I went back to using NSSplitView. NSSplitView is fine for what I need, the thing is that the autoSave of NSSplitView is broken. So I decided to implement it myself.

The thing I am doing at the moment is resizing 1 of the subviews of the NSSplitView.

What is the proper way of resizing an NSSplitView? - setPositionOfDivider:itIndex: should be the way to go ( haven't tried it ), however I do not know how to get the current position of the divider.

-- thanks in advance

Antwan van Houdt
  • 6,989
  • 1
  • 29
  • 52

2 Answers2

4

In my experience, NSSplitView hates you and wishes you harm. RBSplitView is so much better, it is worth IMO the headache of programatic layout (and I've been so burned with the ShortcutRecorder IB plugins that I will never go back to IB plugins).

That said....

The only way that I know of to determine the current position of the divider is to look at the subviews, find the divider's view, take it's frame, and work out its position keeping in mind the dividerThickness. It is insane that you have to write that code, but the code isn't that incredibly difficult, and you can put it in a category.

Or go back to RBSplitView while you still can, if your needs are ever going to be complicated.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Its for a simple chat window, my needs are not going to become anymore complicated any time soon. I am sure the code is not difficult was just wondering whether there is a *proper* way, as resizing 1 subview did work when the size was 0, anyways iam going to try this now and if it works you'll get a cookie – Antwan van Houdt Mar 04 '11 at 15:24
  • position = subView0.frame.size.height + subView0.frame.origin.x; works -- not the actual code but the way I did it and what does the job – Antwan van Houdt Mar 04 '11 at 16:08
  • Did you mean subView0.frame.size.width? – ericg Aug 30 '11 at 21:31
3

I'm using Swift here but the same method should exist in Objective C:

mySplitter.setPosition(123, ofDividerAtIndex: 0)
Marc Fearby
  • 1,305
  • 1
  • 13
  • 28