我从Rubymotion开发开始,用自定义单元格创建了我的第一个NSTableView。
下面的代码工作正常,但是我不知道应该如何声明带有Teacup布局的NSTableCellView (以便在样式表中移动框架大小)
def tableView(table_view, viewForTableColumn: column, row: row_index)
cell_identifier = 'cell_id'
cell = table_view.makeViewWithIdentifier(cell_identifier, owner: self)
unless cell
cell = NSTableCellView.alloc.initWithFrame(CGRectMake(0, 0, table_view.bounds.size.width, rowHeight))
cell.identifier = cell_identifier
layout(cell) do
subview(NSTextField, :cell_text)
end
end
cell.subviews[0].stringValue = "value for #{row_index}"
cell
end我已经试过这段代码了,但是它不工作:
def tableView(table_view, viewForTableColumn: column, row: row_index)
cell_identifier = 'cell_id'
@cell = table_view.makeViewWithIdentifier(cell_identifier, owner: self)
unless @cell
layout(nil, :root) do
@cell = subview(NSTableCellView, :cell_view) do |cell|
cell.identifier = cell_identifier
subview(NSTextField, :cell_text)
end
end
end
@cell.subviews[0].stringValue = "value for #{row_index}"
@cell
end谢谢你的帮忙
发布于 2014-03-06 04:33:10
如果您指定样式表并调用reapply!,它应该可以工作
cell.stylesheet = :stylesheet
cell.reapply!https://stackoverflow.com/questions/22208389
复制相似问题