On Jun 30, 2011, at 23:13, R wrote:

> Can anyone give me some guidance on adding a button w/ image to a
> tableview using bindings.  I've had good luck adding buttons to a
> tableview by dropping in a button cell.  But adding the image is
> giving me some problems.  The image will be retrieved from the object
> represented on the row of the tableview.  I'm populating the content
> array and tableview via an arrayController.

In IB, drill down to the level of the button cell -- either keep clicking on 
the top row of the column in the layout view until just the cell is selected, 
or select the cell directly in the outline view. Once the cell is selected, you 
should see the "Image" and "Alternate Image" bindings in the Bindings 
inspector. Bind the one(s) that you want to a NSImage property of 
arrangedObjects, and that should be all you need to do.

Alternately, you can do this programmatically by implementing the 
tableView:willDisplayCell:forTableColumn:row: delegate method. After matching 
on the row, column and (for robustness) cell class, just set the cell's image 
to the desired image. I guess this doesn't meet your "using bindings" 
requirement, but sometimes it's easier to do it this way than to derive a 
KVO-compliant image property to use with bindings.


_______________________________________________

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