• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Custom Views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom Views


  • Subject: Custom Views
  • From: Matt Mashyna <email@hidden>
  • Date: Tue, 11 Apr 2006 16:19:07 -0400

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Custom Views
      • From: Wain <email@hidden>
  • Prev by Date: slow drawRect not displaying correctly
  • Next by Date: Re: SLOW -[NSFileManager directoryContentsAtPath:matchingExtension:options:keepExtension:]
  • Previous by thread: Re: slow drawRect not displaying correctly
  • Next by thread: Re: Custom Views
  • Index(es):
    • Date
    • Thread