1

我正在开发一个在 OutlineView 上显示数据列表的应用程序。控制器收到通知,告诉它更改一行的状态 NSImageCell 的图像。问题是我无法刷新 OutlineView 行上的单元格。

到目前为止,我已经尝试了以下代码中的每个选项。

id dataCell = [self dataCellWithID:@"cellID" andRow:rowNumber];
if (dataCell && [dataCell isKindOfClass:[NSImageCell class]]) {
    //OPTION 1
    NSImageCell *statusIconCell = (NSImageCell *)dataCell;        
    [statusIconCell setImage:[NSImage imageNamed:[self syncIconNameForStatus: syncState]]];  

    //OPTION 2
    [dataCell setObjectValue:[NSImage imageNamed:[self syncIconNameForStatus: syncState]]];
    [dataCell reloadData];

    //OPTION 3
    NSIndexSet *rowIndex = [NSIndexSet indexSetWithIndex:listRow];
    NSIndexSet *columnIndex = [NSIndexSet indexSetWithIndex:[outlineView columnWithIdentifier:@"cellID"]];
    [outlineView reloadDataForRowIndexes:rowIndex columnIndexes:columnIndex];    
}

有任何想法吗?

提前致谢。

米基万。

4

1 回答 1

1

找到了解决方案!

id dataCell = [self dataCellWithID:@"cellID" andRow:listRow];
if (dataCell && [dataCell isKindOfClass:[NSImageCell class]]) {
    NSImageCell *statusIconCell = (NSImageCell *)dataCell;        
    [statusIconCell setImage:[NSImage imageNamed:[self syncIconNameForStatus:syncState]]];  
    [[statusIconCell controlView] setNeedsDisplay:YES];
}
于 2011-06-14T18:30:06.307 回答