Dr. H. Nikolaus Schaller wrote:
at is exactly what the current code is thought for. But at least on
10.5
it did not (yet). Subviews are evenly split (e.g. 50%, 50%). Maybe,
I have
made some mistake so I will try to look again in that direction...
Below is a small method that resizes all subviews of a split view
such that
they have (up to rounding errors) the same height. Works for me on
10.5.
Wolfgang
- (void)spaceEvenly:(NSSplitView *)splitView
{
// get the subviews of the split view
NSArray *subviews = [splitView subviews];
unsigned int n = [subviews count];
// compute the new height of each subview
float divider = [splitView dividerThickness];
float height = ([splitView bounds].size.height - (n - 1) *
divider) / n;
// adjust the frames of all subviews
float y = 0;
NSView *subview;
NSEnumerator *e = [subviews objectEnumerator];
while ((subview = [e nextObject]) != nil)
{
NSRect frame = [subview frame];
frame.origin.y = rintf(y);
frame.size.height = rintf(y + height) - frame.origin.y;
[subview setFrame:frame];
y += height + divider;
}
// have the AppKit redraw the dividers
[splitView adjustSubviews];
}