Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Samppaa

macrumors regular
Original poster
Mar 26, 2010
168
23
What I basically want to do do is add image into my table cell(At the left) and increase the height of my table cell, so there would be image and text next to it. This might sound dumb, but I actually didn't find a good tutorial which teaches how to do this easily :S Thanks in advance..
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
I have done that by subclassing NSTextFieldCell and overriding -drawInteriorWithFrame:inView: , which requires you to do the math and draw the contents appropriately. Of course, your cell does need to be able to obtain the correct image - since it is a custom format, you could do that by passing the table a dictionary or array with both the text and the image. Alternately, you can deliver the image in tableView:willDisplayCell:forColumn:row:

If your table does not have column-reordering, you could just add a NSImageCell next to the column in question.
 

Samppaa

macrumors regular
Original poster
Mar 26, 2010
168
23
It doesn't have reordering I could use that way, but how can I increase the height of the cell so it fits in correctly?
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
It doesn't have reordering I could use that way, but how can I increase the height of the cell so it fits in correctly?

You would have to set the row height, which you can do for the whole table in interface builder or programatically, or you can return a variable row height (if there are rows with no image that you want to make smaller, or if you want different sized rows for different images) using a tableview delegate method.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.