NSTableView - setting row heights
NSTableView - setting row heights
- Subject: NSTableView - setting row heights
- From: Peter Hudson <email@hidden>
- Date: Mon, 01 Jun 2009 10:50:26 +0100
Here is the setup ...
Table view with 3 columns.
In tableView:objectValueForTableColumn:row: I return an
NSAttributedString, most of which use 2 different fonts.
To set the row height I have implemented the delegate method :-
-(float)tableView:(NSTableView *)tableView heightOfRow:(int)row
{
NSAttributedString *str = [[data objectAtIndex:row] objectAtIndex:
1]; // recover the longest string
NSTableColumn *col = [[tableView tableColumns] objectAtIndex:1];
// the middle column
NSCell *colDataCell = [[[NSCell alloc] initTextCell:@""] autorelease];
[colDataCell setWraps:YES];
[colDataCell setAttributedStringValue:str];
return [colDataCell cellSizeForBounds:NSMakeRect(0.0, 0.0, [col
width], FLT_MAX)].height + 2;
}
The cell contents are reproduced as expected - row heights vary and
are correct.
I can change column widths and the text is adjusted correctly and the
new row height set.
The table scrolls correctly. Resizing the parent window resizes the
table and the row heights correctly.
The problem appears when I try to select a row. Rows are not selectable.
When I try to select a row I get the error message
NSConcreteMutableAttributedString addAttribute:value:range:: nil value
I have tried hard coding into
tableView:objectValueForTableColumn:row: a simple attributed string
which
works in another app without any problem. But this produces the same
error message.
I have used this technique of returning NSAttributedStrings to
NSTableView s many times previously with no problem.
I'm using xCode 3.1 Targeting OSX 10.4 and its a universal build.
Any help would be much appreciated.
Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden