4

我正在尝试创建一个以空字符串作为标识符的列,但每次我尝试创建该列时,Cocoa 似乎都会用单词“Field”替换空字符串。你怎么解决这个问题?

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

1 回答 1

10

列的标识符与其标题不同。你想设置它的 -headerCell 的字符串值:

[[columnColumn headerCell] setStringValue:@""];
于 2010-01-25T18:14:48.907 回答