9

Is it possible to achieve the following just using the auto-layout options available from Xcode? For example by changing hugging or compression settings.

Expanding only one panel of an NSSplitView using auto-layout

What is the recommended way of achieving this resize behaviour?

Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62

1 Answers1

23

If you want to achieve a fixed left panel, just select the left view in Interface Builder an choose "Editor" → "Pin" → "Width". This will make the divider unmovable, though.

If you want to keep a draggable divider, you can use the "Holding Priorities" slider in IB. To prioritize growth of the right panel, select the split view in IB and lower the "Right" holding priority to 1.
Note that those priorities have been added in Mountain Lion. Details can be found in the 10.8 AppKit release notes.

If you need to support 10.7, achieving this NSSplitView behavior might be way harder. Apple fixed several bugs and shortcomings with 10.8 (especially in conjunction with split views).

Thomas Zoechling
  • 34,177
  • 3
  • 81
  • 112
  • Why would you have a movable slider if there is a pane of a fixed size? – uchuugaka Jul 15 '13 at 08:32
  • 1
    Why not? This is the default in almost all OS X applications that have a sidebar (e.g. the Finder). The source list doesn't grow when resizing the window but it is freely positionable. – Thomas Zoechling Jul 15 '13 at 08:55
  • Oh. I see what you mean. Good example. So holding position is where it should stay until the user adjusts it manually? I wish the docs used clear language. – uchuugaka Jul 15 '13 at 09:22
  • 4
    Just a note for others, *Holding Priorities* is found under the `NSSplitView`'s size inspector, so make sure the split view is selected (no one of the split views panels). – Daniel Farrell Jul 15 '13 at 23:06
  • 3
    Where is that "Editor" → "Pin" → "Width"? I don't have it :( (Xcode 7.2) – falkon21 May 04 '16 at 16:08