Objective c 命名NSTableColumn时出现问题
我试图创建一个以空字符串作为标识符的列,但Cocoa似乎每次尝试创建该列时都会将空字符串替换为单词“Field”。你怎么处理这件事Objective c 命名NSTableColumn时出现问题,objective-c,cocoa,nstableview,nstablecolumn,Objective C,Cocoa,Nstableview,Nstablecolumn,我试图创建一个以空字符串作为标识符的列,但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
- (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:@""];
我认为这在代码上相当不直观。NSControl和子类将消息传递给它们的单元格。我认为NSTableColumn应该有一个-title/-setTitle:方法,该方法将字符串传递给头单元格的字符串值。有人应该提交一个增强请求。。。但我太懒了,不想……-)