【发布时间】:2012-06-10 06:23:01
【问题描述】:
我有一个基于视图的 nstableview。我想根据我在下面使用代码的某些条件为整行着色
- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row
{
NSTableRowView *view = [[NSTableRowView alloc] initWithFrame:NSMakeRect(1, 1, 100, 50)];
[view setBackgroundColor:[NSColor redColor]];
return view;;
}
委托方法被调用,但表似乎没有使用委托方法返回的NSTableRowView。
这里的主要目的是根据某些条件为整行着色。上面的实现有什么问题?
【问题讨论】:
-
要设置backgroundColor,需要使用
- (void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row in your NSTableViewDelegate.下面看我更详细的回答。
标签: cocoa nstableview