![](/img/trans.png)
[英]Problem retrieving NSCell data via [NSTableColumn dataCellForRow]
[英]Problem naming 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 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:@""];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.