我正在尝试禁用特定表中的特定单元格。我希望能够在不久的将来针对整个专栏文章进行所有这些工作,但现在我正在尝试一些事情。
tc1和tc2代表NSTableColumns,而tv代表NSTableView。
但是,代码将编译并运行,但仍启用了第2行和名为“ column1”的表列中的单元格。我需要怎么做才能使其禁用?
下面的代码示例:
-(id)init
{
self = [super init];
if (self)
{
arr = [[NSMutableArray alloc] init];
[tc1 setIdentifier:@"colum1"];
[tc2 setIdentifier:@"colum2"];
[tv setDelegate:self];
}
return (self);
}
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if([[aTableColumn identifier] isEqualToString:@"column1"])
{
if (rowIndex == 2) // myindex holds the row index where I need to disable the cells
{
[aCell setEnabled:NO];
}
}
else
{
[aCell setEnabled:YES];
}
}
声明标识符时出现拼写错误。解决。