[英]Get a reference to an extra text field in an NSTableCell
I made a subclass of NSTableCell and made it the data source and delegate of the table. 我做了一个NSTableCell的子类,并使其成为数据源和表的委托。
The table is view based. 该表是基于视图的。
The cell was an image and text cell that i added an extra text field into. 该单元格是一个图像和文本单元格,我在其中添加了一个额外的文本字段。
I have a referencing outlet for the extra field in the subclass. 我为子类中的额外字段提供了一个引用出口。
I have connected the extra field referencing outlet from the table view cell in IB to the extra field. 我已将IB中表格视图单元格的额外字段引用出口连接到额外字段。
Everything in the table still works as before i subclassed the cell view and moved all the data source and delicate code over there. 表中的所有内容仍然像我将单元视图子类化并将所有数据源和精致代码移到那里之前一样工作。
But.. I still can not reference the new extra field in the delicate method within the subclass as I expected to be able to. 但是..我仍然无法像我期望的那样在子类内的精致方法中引用新的额外字段。
See below what i expected to be able to do now. 请参阅下面我希望现在可以做的事情。 But the tableCellDate (the new field in the cell) is not recognised as an available reference.?
但是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.