Search code examples
objective-cmacoscocoanssplitview

Set Fixed Height for NSSplitView subview


OK, so here's the deal :

  • I'm having a vertical NSSplitView (actually using DMSplitView sublass) with 2 subviews in it
  • I want the bottom one to be of fixed height
  • DMSplitView manages to "fix" its size under certain conditions (e.g. when the window is resized the bottom view stays as is)
  • However, if the user tries to drag-resize the view (although both min/max constraints have been set) he's able to, which means that the bottom view is not of fixed height after all.

And this all of my (related) code :

[_mainHorizontalSplitView setMinSize:25 ofSubviewAtIndex:1];
[_mainHorizontalSplitView setMaxSize:25 ofSubviewAtIndex:1];

So, any ideas of a possible workaround for this?


Solution

  • Just found it (actually a modification to DMSplitView delegate) :

      - (CGFloat)splitView:(NSSplitView *)splitView 
    constrainSplitPosition:(CGFloat)proposedPosition 
               ofSubviewAt:(NSInteger)dividerIndex
      {
           return [self positionOfDividerAtIndex:dividerIndex];
      }