Reputation: 6746
I have added a tableview and as well configured the cell with an identifier. Everything works fine, the text of the cell gets displayed. I have just one problem and don't know how to solve it. How can I change the image of the tableview cell?
Here is my code:
func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? {
let cellView = tableView.makeViewWithIdentifier("cell", owner: self) as! NSTableCellView
cellView.textField!.stringValue = self.objects.objectAtIndex(row) as! String
return cellView
}
How can I change the image which is also present inside the cell?
Upvotes: 1
Views: 1778
Reputation: 285059
The standard NSTableCellView
with text and image has an outlet imageView
cellView.imageView!.image = NSImage(named:"MyImage")
Upvotes: 3