相关疑难解决方法(0)

带有标识符的 NSTableView 单元格保持为零

我正在构建 MacOS 应用程序。当我按下添加按钮时,我正在尝试制作更新单元格的表格视图。

在此处输入图片说明

以下是我的代码:

 func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
    let identifier = tableColumn?.identifier as NSString?
    if ( identifier == "NameCell")
    {
        var result: NSTableCellView
        let cell = tableView.make(withIdentifier: "NameCell", owner: self) as! NSTableCellView
        cell.textField?.stringValue = self.data[row].setting!
            return cell

    }
    else if (identifier == "SettingCell")
    {
        if let cell = tableView.make(withIdentifier: "SettingCell", owner: self) as? NSTableCellView {
        cell.textField?.stringValue = self.data[row].setting!
        return cell
    }
    }
    return nil
}
Run Code Online (Sandbox Code Playgroud)

但是,行 let cell = tableView.make(withIdentifier: "NameCell", owner: …

macos cocoa nstableview nstableviewcell swift3

4
推荐指数
2
解决办法
3297
查看次数

标签 统计

cocoa ×1

macos ×1

nstableview ×1

nstableviewcell ×1

swift3 ×1