PDA

View Full Version : [Resolved] NSImage in NSTableView column




larswik
Dec 2, 2011, 03:15 PM
I have an NSTableView with about 6 columns. All the columns are text but the first one I want as an NSImage. Reading through the docs it seems that a cell can be text or image initWithText or initWithImage. So in a delegate method for the tableview I had it look at the identifier and if it was the image it would make an image Cell and return that instead of the default which seems to be the text Cell. The end result is a blank column?
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
Item *newItem = [tableViewItemList objectAtIndex:row];
NSString *identifier = [tableColumn identifier];

if ([identifier isEqualToString:@"image"]) {
NSCell *imageCell = [[NSCell alloc] initImageCell:newItem.image];
return imageCell;
}
else
return [newItem valueForKey:identifier];

}



larswik
Dec 2, 2011, 04:53 PM
I got it working. I dragged in an Image Cell and dropped in on my first column and now the images load just fine.

Could someone tell me how to mark this thread solved, I can't seem to find it?

kainjow
Dec 3, 2011, 01:04 PM
Could someone tell me how to mark this thread solved, I can't seem to find it?

Here you go. (http://guides.macrumors.com/Help:MacRumors_FAQ#How_do_I_mark_my_thread_to_show_that_the_problem_has_been_solved.3F)