簡體   English   中英

獲取對NSTableCell中額外文本字段的引用

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM