seeking advice on NSComboBox and view display problems
seeking advice on NSComboBox and view display problems
- Subject: seeking advice on NSComboBox and view display problems
- From: Carrie Brezine <email@hidden>
- Date: Tue, 4 Feb 2003 11:17:10 -0500
hello,
I'm a relative newbie and in desperate need of a sounding board. At
this point I think some of my problems might not be due to my ignorance
alone, so I'd really appreciate any insight from more experienced
folks. Here's the situation:
I'm trying to make a view and associated controller (subclass of
NSWindowController). The view will be used in a couple different
windows in my app. What I'd like on the view is nine matrices of combo
boxes, six editable text fields, a text view, and a few buttons. Those
matrices are three rows by one column-- I'd settle for three matrices
of nine rows each, at this point I don't much care! I got the
interface all built and laid out the way I wanted it, then selected all
the controls and did "Layout > make subviews of > box". In my app,
the WindowController has an accessor method - (id)colorView; which
returns the contentView of the box. What I usually do is call/create a
shared instance of the windowController, show the panel, retain the
box, and set the contentView of a box on my active window to colorView.
Struggled with this many hours, and for some reason on this nib,
*nothing*. Null every time. The box and contentView are null in the
init method, null in awakeFromNib, null in WindowDidLoad--- even though
individual controls, such as a random textField or label, can be
accessed and appear to exist. I broke and reconnected all of the
connections, still nothing. Finally I tried creating an entirely new
nib. Still no luck. This morning I created yet another fresh nib with
only two controls, two NSTextFields. Made a subview of this in a box,
and hooray! I could display the contentView of the box in the place
where I want it. Usually my accessor method is
- (id)colorView
{
//colorView is of type NSBox
return [colorView contentView];
}
this time I used
-(id)colorView
{
//colorView is of type NSView, outlet connected to the content of the
box
return colorView;
}
I'd prefer to be consistent but at this point, whatever works. (still
wish I understood why, though...)
Since that worked, I decided ok, let me add all the controls I need to
this new nib. Made three matrices of those pesky combo boxes, a couple
of text fields, went to save it and-- IB crashed! This happened to me
uncountable times last week when working with matrices of combo boxes
but I thought I'd worked around it by making the matrices smaller. Now
the nib won't open. Frustration is an understatement. And I'm very
confused.
Has anyone else had trouble with matrices of NSComboBoxes? especially
IB crashing? It would make me feel *much* better to know I'm not alone.
Do nibs get corrupted to the point where they act bizarrely? What is
going on when the nib can't be opened in IB or PB? How do they get
corrupted?
Is it possible that my problems in displaying this view are due to the
comboBox matrices?
Am I missing something with the layout>make subviews of > box command?
should the content of this box be NULL in windowDidLoad and
awakeFromNib? It's not that way in other situations like this which
are working. Shouldn't the controls be accessible programmatically
after you call initWithWindowNibName:?
Any feedback appreciated. The code which is not working is below; if
anyone can tell me what's wrong with it that would be great too.
sorry this is so long-- thanks for your patience
Carrie
// code-- not working!
// the window contoller
@implementation ColorVC
///////////////////////////////////////////////////////////////////////
///////
//creation destruction opening up
///////////////////////////////////////////////////////////////////////
///////
+ (id)sharedColorVC
{
static ColorVC *_sharedColorVC = nil;
if (!_sharedColorVC)
{
_sharedColorVC =
[[ColorVC allocWithZone:[self zone]] init];
}
return _sharedColorVC;
}
- (id)init
{
NSLog(@"initializing ColorVC");
self = [self initWithWindowNibName:@"ColorView"];
//initialize ivars here
NSLog(@"color view completing initialization");
NSLog(@"color nib description: %@", [self description]); this does
print an address so nib appears to exist
return self;
}
- (void)dealloc
{
[super dealloc];
}
//get view and hide everything else
- (void) windowDidLoad
{
NSLog(@"color view did load method");
[super windowDidLoad];
NSLog(@"colorView content here is %@", [[colorView contentView]
description]); (null)
[colorView retain];
NSLog(@"colorView content after retain is %@", [[colorView
contentView] description]); (null)
[self setWindow:nil];
}
//use awake from nib to display correctly
- (void)awakeFromNib
{
NSLog(@"is the colorview ever awaking from nib? yes!");
NSLog(@"colorView content in awakefromNib is %@", [[colorView
contentView] description]);
//prints colorView content in awakeFromNib is null
}
///////////////////////////////////////////////////////////////////////
///////
//Accessors
///////////////////////////////////////////////////////////////////////
///////
- (id) colorView
{
NSLog(@"color View is returning %@", [colorView contentView]);
return [colorView contentView];
}
- (void)setColorView:(id)newView
{
[colorView setContentView:newView];
}
@end
//called in another window controller's awakeFromNib method by
[[ColorVC sharedColorVC] showWindow:self];
[colorBox setContentView:[[ColorVC sharedColorVC] colorView]];
colorBox is a box on this main window; this code results in an empty
box.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.