gpt4 book ai didi

objective-c - 命名 NSTableColumn 的问题

转载 作者:太空狗 更新时间:2023-10-30 03:59:16 27 4
gpt4 key购买 nike

我正在尝试创建一个以空字符串作为标识符的列,但每次我尝试创建该列时,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];
}

最佳答案

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

[[columnColumn headerCell] setStringValue:@""];

关于objective-c - 命名 NSTableColumn 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2134478/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com