Programmatically Resize NSSplitView

I used and loved RBSplitView, however I was not able to redefine it programmatically, since a certain version of xcode no longer supports IB plugins.

So I returned to using NSSplitView. NSSplitView is great for what I need, the fact is that NSSplitView autosave is broken. Therefore, I decided to implement it myself.

What I'm doing right now is resizing one of the NSSplitView subzones.

What is the correct way to resize NSSplitView? - setPositionOfDivider: itIndex: there should be a way to go (haven't tried it), however I don't know how to get the current position of the separator.

- in advance

+6
objective-c xcode cocoa appkit nssplitview
source share
2 answers

In my experience, NSSplitView hates you and wishes you harm. RBSplitView much better, it costs IMO the headache of software layout (and I was so burned with the ShortcutRecorder IB plugins that I will never return to IB modules).

That said ....

The only thing I know to determine the current position of the separator is to look at the sub-items, find the type of separator, take it in the frame and work out its position, referring to dividerThickness . It's crazy that you need to write this code, but the code is not so incredibly complex, and you can put it in a category.

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

+4
source share

I use Swift here, but the same method must exist in Objective-C:

 mySplitter.setPosition(123, ofDividerAtIndex: 0) 
+1
source share

All Articles