Re: NSTableView custom class
Re: NSTableView custom class
- Subject: Re: NSTableView custom class
- From: Henri Lamiraux <email@hidden>
- Date: Sun, 22 Jul 2001 13:12:19 -0700
When subclassing a built in class DO NOT RELY on any initXXXX methods (like
initWithFrame:). If you using a custom view then your initWithFrame will be
called but it is still better to implement awakeFromNib. At init time
(initWithFrame, initWithCoder, ...) no outlets or actions have been set up
yet and all your outlets will be NULL.
All post nib loading initialization has to be done in awakeFromNib.
Henri Lamiraux
email@hidden
InterfaceBuilder Engineering Manager
--
To get random signatures put text files into a folder called 3Random
Signatures2 into your Preferences folder.
>
From: Oscar Bascara <email@hidden>
>
Date: Sun, 22 Jul 2001 10:27:22 -0700
>
To: email@hidden
>
Subject: Re: NSTableView custom class
>
>
Well, it works now after some experimentation, and here's a follow-up.
>
In PB, I incorrectly picked CustomView from the palette (and then
>
specified my NSTableView subclass as the custom class). This meant I
>
would have to override the initWithFrame: method, as I tried to below.
>
What I needed to do was pick the NSTableView from the palette directly,
>
and along with it I get NSScrollView. It would probably be hard to get
>
an NSTableView from a CustomView.
>
>
In creating custom classes, when do I choose CustomView and when do I
>
choose the superclass itself from the palette? Sometimes it seems I
>
have to do it one way and sometimes the other way. In this case, I had
>
to choose the superclass. When I was customizing NSSlider, I had to
>
choose CustomView. Also, in the Learning Cocoa project called ToDo,
>
with customizing NSMatrix, CustomView is picked for creating
>
NSCalendarMatrix and NSMatrix (which I can't actually find on the
>
palette, how did they select it) is picked for creating
>
SelectionNotifyMatrix.
>
>
Oscar
>
>
On Sunday, July 22, 2001, at 12:43 AM, Oscar Bascara wrote:
>
>
> I'm trying to subclass NSTableView but the scroll bars never show up
>
> with the rows eventually going off the window frame. Also the rows
>
> grow from bottom to top instead of top to bottom. What's incorrect
>
> with my initWithFrame: method for the subclass? I'm pretty sure I'm
>
> missing stuff. For example, how do I even access the underlying
>
> NSScrollView to set vertical scroll bars?
>
>
>
> - (id)initWithFrame:(NSRect)frameRect
>
> {
>
> if (self = [super initWithFrame:frameRect]) {
>
> [self setAllowsEmptySelection:NO];
>
> [self setAllowsMultipleSelection:NO];
>
> [self setAllowsColumnSelection:NO];
>
>
>
> [self setDrawsGrid:YES];
>
>
>
> [self setRowHeight:15.0];
>
> tableColumn = [[NSTableColumn alloc]
>
> initWithIdentifier:@"name"];
>
> [self addTableColumn:tableColumn];
>
> [self sizeLastColumnToFit];
>
> }
>
> return self;
>
> }
>
>
>
> Oscar
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev