Question

Je travaille sur une application qui affiche une liste de données sur un OutlineView. Le contrôleur reçoit des notifications qui lui dit de changer l'image de l'état NSImageCell d'une ligne. Le problème est que je ne pouvais pas réussi à rafraîchir la cellule sur la ligne de la OutlineView.

Jusqu'à présent, je l'ai essayé chacune des options sur le code suivant.

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];    
}

Toutes les idées?

Merci à l'avance.

Mikywan.

Était-ce utile?

La solution

trouvé la solution!

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];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top