TabView / TabViewItem / Inserting Views Problem
TabView / TabViewItem / Inserting Views Problem
- Subject: TabView / TabViewItem / Inserting Views Problem
- From: Sam Goldman <email@hidden>
- Date: Mon, 29 Oct 2001 20:31:47 -0800
OK, thanks a ton to those of you who replied to my last question about
programmatically adding views to a NSTabViewItem. I have that working now!
I am having a problem concerning similar matters. When I try to add a new
NSTabViewItem and put a NSScrollView into it and a NSTextView into that, the
NSTextView is acting like it doesn't exist. I believe that, due to the order
of my code, the NSTextView is either not created or is infinitesimally
small.
I am just going to post the relevant code. It all should make sense, but it
seems a little (a lot) cluttered.
- (void)makeNewTab:(NSString *)myTitle atPath:(NSString *)myPath
{
id *dummy;
NSTabViewItem *tabViewItem = [[NSTabViewItem alloc]
initWithIdentifier:myTitle];
NSScrollView *theScrollView;
NSTextView *theTextView;
NSString *fileContents = [[NSString stringWithContentsOfFile:myPath]
retain];
[tabViewItem setLabel:myTitle];
[tabView addTabViewItem:tabViewItem];
theScrollView = [[NSScrollView alloc] initWithFrame:[[tabViewItem view]
bounds]];
theTextView = [[NSTextView alloc] initWithFrame:[theScrollView bounds]];
[theScrollView setHasVerticalScroller:YES];
[tabViewItem setView:theScrollView];
[theScrollView setDocumentView:theTextView];
[theTextView setString:fileContents];
[tabView selectLastTabViewItem:(id)dummy];
[theScrollView release];
[theTextView release];
[tabViewItem release];
[fileContents release];
}
I am open to *any* suggestions.
Thanks a ton for all your help to everyone on this list!
- Sam