我正在开发一个在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];
}有什么想法吗?
提前谢谢。
密基万。
发布于 2011-06-15 02:30:06
找到解决方案了!
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];
}https://stackoverflow.com/questions/6335871
复制相似问题