首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSImageCell更改图像问题

NSImageCell更改图像问题
EN

Stack Overflow用户
提问于 2011-06-14 04:24:19
回答 1查看 1.5K关注 0票数 1

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

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

代码语言:javascript
复制
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];    
}

有什么想法吗?

提前谢谢。

密基万。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-15 02:30:06

找到解决方案了!

代码语言:javascript
复制
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];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6335871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档