Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom Views



I've been looking for a way to create a custom container view so I can instantiate as many as I need and add them as subviews in a window. I thought I could make a subclass of NSView with a few text views in it, instantiate it in a nib, connect the outlets and have it ready to use. Of course, this doesn't work. I was able to make the views and drop them with the code below but the subviews are not connected to the outlets and they don't draw.

- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window.

NSWindowController* myController = [[self windowControllers] objectAtIndex:0];
NSWindow* myWindow = [myController window];
NSView* mainView = [myWindow contentView];
NSRect initPos = {{0.0, 0.0}, {200.0, 100.0}};

planBoxView* newView = [[planBoxView alloc] initWithFrame: initPos];

[mainView addSubview: newView];
[newView setNeedsDisplay: YES];
}


I can see in the debugger that the view I make this way is added but its outlets are nils.

I want to make views for a project planner like MS Project. I want one view with a few subviews connected to outlets. I was hoping that I could make a view in IB and use it to drop them into my window on the fly. Is there way to do it this way with IB or do I need to lay my custom view out programatically ?

Is there a tech note for this ? I just can't find any Apple example code that covers this kind of thing.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.