Cocoa – How to disable resizing of the subview of NSSplitView in Interface Builder

cocoainterface-buildernssplitview

I've created in Interface Builder a NSSplitView with two subviews. I want the left-side view to have fixed width. I've tried to define autosizing rules for both subviews but the left subview still changes width on window resizing (split view fills up a window). May be that caused by NSSplitView's Autoresizes Subviews property? (I can't uncheck it). What can I do?

Best Answer

The best way I found to do this in Interface Builder:

  • Drop the NSSplitView on the window
  • Select the Custom View you want fixed
  • Go up to the Xcode menu and select Editor > Pin > Width
  • Adjust the Constant in the Attributes Inspector to the size that you want the panel to be fixed at

Of course, you can also add this layout constraint through code as suggested above if you're feeling adventurous.

Related Topic