8

I want to implement a 3-pane vertical NSSplitView (very similar to Mail.app). I'm not really sure where to start. I'm pretty sure I need to implement a NSSplitViewDelegate, but I'm not sure which methods and / or their implementations.

The layout I want is the following:

+----------+------------------+------------------------------------+
|          |                  |                                    |
|          |                  |                                    |
|          |                  |                                    |
|          |                  |                                    |
|  Pane 1  |      Pane 2      |               Pane 3               |
|          |                  |                                    |
|          |                  |                                    |
|          |                  |                                    |
|          |                  |                                    |
|          |                  |                                    |
+----------+------------------+------------------------------------+

I want to implement the following constraints for each of the panes:

  • Pane 1: Minimum 140pt. Maximum: 400pt.
  • Pane 2: Minimum 250pt.
  • Pane 3: Minimum 400pt.

Any pointers would be much appreciated.

Olly
  • 3,409
  • 3
  • 24
  • 28
  • 1
    Views can be hierarchical so you might consider making two levels of split-view: one at the top with "Pane 3" on the right and a 2nd split-view on the left (that contains "Pane 1" and "Pane 2"). I have not tried that but it seems like the simplest way to make this work. – Kevin Grant Jul 31 '12 at 02:06
  • Great tutorial here: http://www.youtube.com/watch?v=k3XLInzZIs8 – siekfried Sep 18 '13 at 10:03

4 Answers4

10

It is pretty simply in Xcode 8.2.1

  1. Just add a Split View Controller in Interface Builder.
  2. Add an additional View Controller.
  3. Crtl + mouse press on the Split View Controller and drag to the additional View Controller.
  4. Select split items.

That's it.

asdf
  • 952
  • 14
  • 13
9

To enforce a minimum size, check out the BESplitViewConstraintEnforcer utility class we created.

By the way: if you want to avoid nesting split views and instead add an additional pane in Interface Builder, drag the new view into the split view object, as shown in the screenshot below.

Screenshot

Philipp
  • 891
  • 1
  • 11
  • 12
7

Actually, HTH inspired me to try a third possibility in Interface Builder, and it turns out to work beautifully. In particular, moving one separator does not make any unintended changes elsewhere, which could easily happen if you'd nest the split views.

  • Add an NSSplitView to you window,
  • Add an NSView (a custom view, in IB) as a child of the Split View. You end up with a split view that has three, not two, subviews.

What it looks like in the IB Objects List

The same works if you'd add another NSSplitView as a child, although you'd have to be careful how the nested split views affect each other. The image above shows how it'd look in interface builder, the second shows the result in the Simulator.

The result

Carelinkz
  • 936
  • 8
  • 27
1

I guess that you did solve this. Anyway, there are two ways. The first is like the answer above, drag a splitview where you want it, and drag a second splitview inside one of the containers ( subview of the splitview ). The view hierarchie is like

Window 
Window containerview
        Splitview
            Containerview_left | containerview_right
                                    Splitview
                                        Containerview_left | containerview_right

If you by code, then you create a splitview, add it as an subview of the window,view. Then you create splitview subviews by adding them using [splitview addsubview] if you add three subviews, you have two deviders. The hierarchie is different.

Window  Window containerview
         Splitview
             Containerview_ind(0)| Containerview_ind(1) | Containerview_ind(2)

This means, if you want to find a subview, you have to know how you did created it.

HTH

Lord iPhonius
  • 173
  • 2
  • 11