Hi,

I need to draw the background of a single row in a tableview. This row is not the selected row, and it changes often. I have more or less got it working but it seems like a bit of a hack so I'm wondering if there is a better way. I've also checked various examples but most want to draw the selected rows differently, not an arbitrary row.

At the moment I subclass the cell for each of the columns of the view ( same subclass). In my delegates objectValueForTableColumn I set a variable 'shouldDrawRow' to true if that is the 'special' row I want to draw myself.

In the cell subclass I override drawInteriorWithFrame and check to see if this value is set in my delegate and if so call a delegate method to draw the background first.

This seems like a real hack as it assumes that drawInteriorWithFrame will be called straight after objectValueForTableColumn. This is sort of reasonable because the cell is reused all the time so it 'works'. The other problem though is I want to draw the ends of the rows differently to the middle ( thin rounded rectangle ) and drawInteriorWithFrame only gives me the rectangle to draw in. I've got no way of finding out which column it is. Again it will work because the columns won't change so I can hard code some values.

However I'm thinking there must be a better way. What I really need is some way of finding out the column and row of the cell about to be drawn, but I can't see it. Am I missing something?

thanks!

Peter
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to