我已经成功地在代码中创建了一个基于单元格的NSTableView。我想让这些单元格更有趣一点,我已经读过,我需要创建一个基于视图的NSTableView。是否有可能纯粹在代码中创建基于视图的NSTableView?
我一直在教程如this。
我的用户界面的其余部分完全在代码中。我一直在努力为这个tableview做同样的事情,但没有多少运气。
这里是我正在定义的TableView - 我需要停止注册笔尖,我不知道如何:
let nib = NSNib(nibNamed: "TransactionCellView", bundle: NSBundle.mainBundle())
tableOfTransactions.registerNib(nib!, forIdentifier: "TransactionCellView")
tableOfTransactions.headerView = nil
tableOfTransactions.setDelegate(self)
tableOfTransactions.setDataSource(self)
tableOfTransactions.reloadData()
这里是我的存根代码每个单元格:
func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView?{
var testCell = NSView()
testCell.frame = NSRect(x: 0, y: 0, width: 300, height: 200)
return testCell
}
任何指示或建议如何实现这一点将不胜感激!
如果你不注册注册表会发生什么? – Willeke