BackgroundColor在NSTableCellView中不起作用

时间:2015-02-03 00:10:47

标签: xcode cocoa background nstableview nstablecellview

为什么backgroundColor不能与所有者一起使用:self.table?它只适用于所有者:self,但是,第二个选项-awakeFromNib被多次调用。

setStringValue适用于这两个选项。

- (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    NSTableCellView *cell = [tableView makeViewWithIdentifier:@"MainCell" owner:self.table];
    [cell.textField setStringValue:@"FunWithFlags"]
    cell.layer.backgroundColor = [[NSColor greenColor] CGColor];
    return cell;
}

1 个答案:

答案 0 :(得分:0)

所有者param需要加载和实例化NIB的所有者对象,以使用提供的标识符创建新视图。 表对象self.table不是任何nib的所有者,因此它不返回任何视图。