1
這是我的表視圖代表:如何在NSTableView中使用NSButtoncell類型設置單元格的背景顏色?
- (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。如何解決它?
任何幫助,將不勝感激。
我的歉意,我是新來的可可。需要更頻繁地閱讀文檔。謝謝! – Irwan 2010-01-15 02:20:02