[英]Get a reference to an extra text field in an NSTableCell
我做了一个NSTableCell的子类,并使其成为数据源和表的委托。
该表是基于视图的。
该单元格是一个图像和文本单元格,我在其中添加了一个额外的文本字段。
我为子类中的额外字段提供了一个引用出口。
我已将IB中表格视图单元格的额外字段引用出口连接到额外字段。
表中的所有内容仍然像我将单元视图子类化并将所有数据源和精致代码移到那里之前一样工作。
但是..我仍然无法像我期望的那样在子类内的精致方法中引用新的额外字段。
请参阅下面我希望现在可以做的事情。 但是tableCellDate(单元格中的新字段)未被识别为可用引用。
class SubclassOfNSTableCellView: NSTableCellView, NSTableViewDelegate{
@IBOutlet weak var tableCellDateField: NSTextField!
// other ib outlets are here
func tableView(tableView: NSTableView!,viewForTableColumn tableColumn: NSTableColumn!, row: Int) -> NSView! {
var cell = tableView.makeViewWithIdentifier("MainCell", owner: self) as NSTableCellView
var theDisplayName: String = recordingsDictionaryArray[row]["name"] as String
cell.textField?.stringValue = theDisplayName
// what i expected to be able to do below was
// cell.tableCellDateField.stringValue = recordingsDictionaryArray[row]["date"] as String
return cell;
}
尝试:
var cell = tableView.makeViewWithIdentifier("MainCell", owner: self) as SubclassOfNSTableCellView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.