NSTableView禁用特定单元格[关闭]

问题描述 投票:0回答:1

我正在尝试禁用特定表中的特定单元格。我希望能够在不久的将来针对整个专栏文章进行所有这些工作,但现在我正在尝试一些事情。

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];
    }
}
objective-c cocoa nstableview
1个回答
0
投票

声明标识符时出现拼写错误。解决。

© www.soinside.com 2019 - 2024. All rights reserved.