Re: Display NSImage in a NSTableView
Re: Display NSImage in a NSTableView
- Subject: Re: Display NSImage in a NSTableView
- From: Chad Seldomridge <email@hidden>
- Date: Wed, 27 Jun 2007 10:18:10 -0600
By default, the NSTableView uses the class NSTextFieldCell for it's
data cells.
You want to use an NSImageCell. In interface builder, drag the
NSImageCell from the Cocoa-Data palette
onto a column in your NSTableView.
You can also do this in code via NSTableColumn's setDataCell: method.
Chad S.
Date: Wed, 27 Jun 2007 17:11:14 +0200
From: Frederic JECKER <email@hidden>
Subject: Display NSImage in a NSTableView
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Moin list,
I created a simple core data app (..my first one) that simply display
data in a NSTableView.
Now that it is working, i'd like to display a small icon in the
selected
row when the user clicks on a button.
Below my code:
- (IBAction) activate:(id)sender{
NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];
NSString *path=[thisBundle pathForResource:@"primaryKey"
ofType:@"gif"];
NSLog(path);
int row=[table selectedRow];
NSArray *columns = [table tableColumns];
NSTableColumn *column=[columns objectAtIndex:0];
NSImage *image=[[NSImage alloc]init];
[image initByReferencingFile:path];
if([image isValid])NSLog(@"Image OK");
[[column dataCellForRow:row] setImage:image];
}
Note that table is defined as IBOutlet NSTableView *table;
The image seems to be correcly loaded but is not displayed in my
table.
Anyone could help me with this problem ?
Thanks
--
Fred
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden