Re: Putting stuff into a tab view programmatically
Re: Putting stuff into a tab view programmatically
- Subject: Re: Putting stuff into a tab view programmatically
- From: David Watanabe <email@hidden>
- Date: Mon, 29 Oct 2001 02:44:24 -0800
On Sunday, October 28, 2001, at 04:12 PM, Sam Goldman wrote:
NSTextView *myTextView = [[NSTextView alloc] init];
I get the view of the NSTabView's first item (there is only one to
start)
and place the NSTextView into it with this:
[[[tabView tabViewItemAtIndex:0] view] addSubview:myTextView];
Is that right? When I do that, nothing shows up. I have never tried
anything
like this before, and don't really understand what a subview is. Am I
going
about this in the right way?
Mucking with the view hierarchy (as you were with subviews) isn't
necessary to accomplish what you're after.
You need to wrap each NSTextView inside an NSTabViewItem and then
proceed to insert the NSTabViewItem into the NSTabView. It might look
something like this:
NSTextView* myTextView = [[NSTextView alloc] init];
NSTabViewItem* tabViewItem = [[NSTabViewItem alloc] initWithIdentifier:
@"whatever"];
[tabViewItem setView: myTextView];
[tabViewItem setLabel: @"The label that shows up in the tab"];
// now add it to the pre-existing NSTabView
[tabView addTabViewItem: tabViewItem];
// you might have to call [tabView setNeedsDisplay], but I'm not sure.
Dave