nsimagecellは画像の問題を変更します
-
27-10-2019 - |
質問
アウトラインビューに関するデータのリストを表示するアプリに取り組んでいます。コントローラーは、行のステータスnsimagecellの画像を変更するように指示する通知を受信します。問題は、アウトラインビューの行でセルを更新できなかったことです。
これまでに、次のコードの各オプションを試しました。
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];
}
何か案は?
前もって感謝します。
ミキワン。
解決
解決策を見つけました!
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];
}
所属していません StackOverflow