1

这是我的表视图委托:

- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
    id theRecord;
    NSMutableString *gid;

    theRecord = [tableDataSource objectAtIndex:row];
    gid = [theRecord objectForKey:@"gid"];

    if (([gid intValue] % 2) != 0)
    {
        [aCell setDrawsBackground: YES];
        [aCell setBackgroundColor: [NSColor colorWithCalibratedRed: 237.0 / 255.0
                                                             green: 243.0 / 255.0
                                                              blue: 254.0 / 255.0
                                                             alpha: 1.0]];

    }
    else
    {
        [aCell setDrawsBackground: NO];
    }
}

它可以很好地显示普通单元格,但是在我添加一个具有 NSButtonCell 类型的单元格(用于复选框)后,tableview 会冻结。如何解决?

任何帮助,将不胜感激。

4

1 回答 1

1

根据NSButtonCell 参考,您只能为无边框按钮指定背景颜色。您是否尝试过使用无边框纽扣电池?

此外,我找不到NSButtonCellsetDrawsBackground:的方法;我只能为NSTextFieldCell找到它。您是否尝试删除呼叫?

于 2010-01-14T14:25:55.700 回答