NSTableView custom cell problem
NSTableView custom cell problem
- Subject: NSTableView custom cell problem
- From: Andrew Skinner <email@hidden>
- Date: Thu, 6 Jan 2005 17:41:48 +0000
Hello, I'm very new to cocoa so if this is a dumb question please
excuse me. I have searched this list and google and my books but am
still stuck, i'm sure the solution is simple.
I'm trying to create a custom NSCell object which draws a string at a
certain point in a cell and then to use the custom cell in my
tableview.
I have subclassed the NSCell object and created a bespoke
drawInteriorWithFrame method. This seems to be working as expected.
However when I try and use the NSCell subclass in my tableview it
doesn't work, with a bit of hacking i can get it to appear in the table
view but only in the first cell and each new item I add to my
datasource the first cell gets overwritten with another instance of the
cell.
Anyway any suggestions will be most welcome, here's most of the code
that I am using for the tableview, this version simply doesn't work the
custom cell is an instance of customCell:
This is called from awakefromnib to set up the table:
- (void)setupTable {
id cell;
id nameCell;
NSTableColumn *theIconColumn;
NSTableColumn *theTextColumn;
theIconColumn = [table tableColumnWithIdentifier:@"icon"];
theTextColumn = [table tableColumnWithIdentifier:@"title"];
[table setRowHeight:32];
[theIconColumn setWidth:[table rowHeight]];
//Set up image cell
cell = [NSImageCell new];
[theIconColumn setDataCell:cell];
//Set up text cell
nameCell = [[customCell alloc] init];
[theTextColumn setDataCell:nameCell];
}
This is the tableview method:
- (void)tableView:(NSTableView *)view
willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)col
row:(int)row
{
if ([[col identifier] isEqualTo: @"icon"])
{
[cell setImage:[NSImage imageNamed: @"Picture"]];
}
else if ([[col identifier] isEqualTo: @"title"])
{
[cell representedObject];
}
}
_______________________________________________
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