• 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
Re: Images & Alternate Color Rows In Table
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Images & Alternate Color Rows In Table


  • Subject: Re: Images & Alternate Color Rows In Table
  • From: Ryan Stevens <email@hidden>
  • Date: Thu, 25 Jul 2002 10:20:42 -0700

On Thursday, July 25, 2002, at 05:53 AM, David Martin wrote:

On Friday, July 19, 2002, at 11:44 , email@hidden wrote:

I'm trying to setup my NSTableView to alternate its row color. The code I have written seems to work provided there are no columns with images in. If there are images in the columns I get the following build error:

2002-07-19 20:46:01.097 SetTheTableView[328] *** -[NSImageCell setDrawsBackground:]: selector not recognized
2002-07-19 20:46:01.105 SetTheTableView[328] An uncaught exception was raised
2002-07-19 20:46:01.105 SetTheTableView[328] *** -[NSImageCell setDrawsBackground:]: selector not recognized
2002-07-19 20:46:01.106 SetTheTableView[328] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSImageCell setDrawsBackground:]: selector not recognized

The problem is that the only NSCell subclass understanding "background" things is the NSTextFieldCell. If you have an NSImageCell, or an NSButtonCell, you're in trouble.
I ran into the same problem yesterday and currently, the only workaround I can think of is the one provided by /Developer/Examples/AppKit/DragNDropOutlineView/: creating a subclass of NSTextFieldCell capable of displaying images.
On the other hand, Mail.app is able to draw colored backgrounds in its read or flagged columns when you write the appropriate rules.

If anyone has any idea


The only workaround I can think of is to get the image(s) into an NSAttributedString so it can be displayed in an NSTextFieldCell rather than an NSImageCell.


- (NSAttributedString *)attributedStringWithImageAtPath:(NSString *)pathToImage
{
NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initWithPath:pathToImage];
NSTextAttachment *textAttachment = [[[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
NSAttributedString *result = NSAttributedString attributedStringWithAttachment:textAttachment];

[fileWrapper release];
[textAttachment release];

return result;
}

Past that, who knows. Maybe that will help though.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Images & Alternate Color Rows In Table (From: David Martin <email@hidden>)

  • Prev by Date: Re: Proper retain/release etiquette
  • Next by Date: Reliable way to add Application Icon
  • Previous by thread: Re: Images & Alternate Color Rows In Table
  • Next by thread: [OT (?)] Why don't iTunes & Disk Copy work with the same burning devices?
  • Index(es):
    • Date
    • Thread