Re: Small NSTableView
Re: Small NSTableView
- Subject: Re: Small NSTableView
- From: Glenn Zelniker <email@hidden>
- Date: Fri, 27 Oct 2006 18:32:40 -0400
On Oct 27, 2006, at 6:16 PM, Mark Manes wrote:
I played a bit with Interface Builder last night. I wanted to
create a smaller size (i.e. like small and mini in some controls)
for the NSTableView.
I found that I could adjust the row height in pixels but of course
when I do that the font no longer fits. What is the right way to
have a small NSTableView?
There are a couple of ways to do this. One is to implement the -
willDisplayCell:forTableColumn:row: method in the table's data-source/
delegate and set the font explicitly like this:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
[aCell setFont:[NSFont systemFontOfSize:11.0]]; // or pick your own
font
}
Another way to do it is to have your -objectValueForTableColumn:row:
method return an attributed string, like this:
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:
(NSTableColumn *)aTableColumn row:(int)rowIndex
{
return [[NSAttributedString alloc] initWithString:myString
attributes:myAttributes];
}
(usual caveats about autoreleasing omitted for brevity)
HTH,
Glenn Zelniker
_______________________________________________
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