Resizing subviews within NSSplitView programmatically
-
Greetings:
I managed to create & stack two sub-views {NSImageView & NSTextView}
within a NSSplitView per NSTabViewItem. However, the 2nd sub-view
'NSTextView' fills the entire parent view, squishing the first view
{NSImageView}. The user would have to manually move he horizontal bar
down to expose the first view.
Question: How can I programmatically adjust the two views so the user
can actually see sub-view#1? The initial exposure doesn't need to be
50/50%. In fact, it's preferable to have a 75/25% exposure, with the
25% going to the descriptive NSTextView sub-view.
I've tried doing [<subView> setFrame:<NSRect>] and even the setBounds.
But that didn't work.
The following is a snippet of NSTabViewItem #2:
if (!mapImage2_View)
mapImage2_View = [[NSImageView alloc] init];
[mapImage2_View setImage:theImage]; // NSImageView
theItem = [map_TabView tabViewItemAtIndex:1];
[theSplitView addSubview:mapImage2_View];
[tabMemo2_View insertText:@"Insert text here."];
NSSize theSize;
theSize.width = 661; theSize.height = 148;
theFrame.size = theSize;
[tabMemo2_View setBounds:theFrame];
[theSplitView addSubview:tabMemo1_View];
[theItem setView:theSplitView];
[mapImage2_View setNeedsDisplay]; // ...this line is
useless.
[theItem setLabel:@"Two"];
Regards,
Ric. -
Hi Ric,
On Fri, 5 Nov 2004 17:32:10 -0800, Frederick C. Lee
<fclee...> wrote:> Question: How can I programmatically adjust the two views so the user
> can actually see sub-view#1?
Take a look at -[NSSplitView adjustSubviews].
Now that you've looked at it, call -[NSView
resizeSubviewsWithOldSize:] instead. This will call -[NSSplitView
adjustSubviews] in the usual case, but will use the delegate method
-[<delegate> splitView:resizeSubviewsWithOldSize:] should it exist.
-Ken


