我试图将图像添加到NSOutlineView中的单元格:
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
df.locale = Locale.current
df.setLocalizedDateFormatFromTemplate("YYYY-MM-dd")
if ( df.locale.identifier == "fr_FR" ) {df.dateFormat="dd-MM-YYYY"}
if ( myView == 0 ) {
if let c = item as? Competition {
if tableColumn?.identifier == "col1" {
if let view = outlineView.make(withIdentifier: "column1", owner: self) as? NSTableCellView{
if let viewTextField = view.textField{
viewTextField.stringValue = df.string(from: c.date)
}
view.imageView?.image = NSImage(named: "NSSlideshowTemplate")
return view;
}
}
}
}
return nil
}
但它没有用。 我对NSTableView没有问题..
知道为什么吗?
谢谢, 尼古拉斯