简体   繁体   中英

OSX Swift add image into nstableview

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?

在此输入图像描述

标准NSTableCellView用文字和图片具有出口imageView

cellView.imageView!.image = NSImage(named:"MyImage")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM