Question

Je suis en train de créer une colonne avec une chaîne vide comme l'identifiant, mais Cocoa semble remplacer la chaîne vide avec le mot « Champ » à chaque fois que je tente de créer la colonne. Comment allez-vous contourner cela?

- (void)addColumnWithCheckboxToTable:(NSTableView *)table
{
    // Add column with checkbox before all other columns
    // This column will have no title and should be as wide as the checkbox
    NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@" "] autorelease];

    // The checkbox is to be initialised without a title
    NSButtonCell *checkbox = [[[NSButtonCell alloc] initTextCell:@" "] autorelease];
    [checkbox setEditable:YES];
    [checkbox setButtonType:NSSwitchButton];
    [checkbox setImagePosition:NSImageOnly];
    [checkbox setControlSize:NSSmallControlSize];

    // Add column with checkbox to table
    [column setDataCell:checkbox];

    // Add column to table
    [table addTableColumn:column];
}
Était-ce utile?

La solution

L'identifiant d'une colonne n'est pas la même chose que son titre. Vous souhaitez définir la valeur de la chaîne de -headerCell:

[[columnColumn headerCell] setStringValue:@""];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top