首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSTablview NSTextFieldCell SetSelectable -

NSTablview NSTextFieldCell SetSelectable -
EN

Stack Overflow用户
提问于 2013-01-08 22:15:30
回答 1查看 169关注 0票数 0

我试图使其中一个nstextfieldcell在特定条件下不被选中。我附上了示例代码:

代码语言:javascript
复制
 -(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
if(tableView == resizeTV){
    if([[tableColumn identifier] isEqualToString:@"Name"]){
        if([[cell stringValue] isEqualToString:@"Cate"]){
            [cell setSelectable:FALSE];

        }
    }
  }
}

在检查条件时,该单元格仍处于选中状态。我已经将tableview绑定到tabledatasource和datadelegate的类名。我仍然可以选择单元格。我做错了吗?

EN

回答 1

Stack Overflow用户

发布于 2013-05-04 13:30:24

使用NSTableView方法取消选择单元格setSelectionHighlightStyle:

代码语言:javascript
复制
-(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
    if(tableView == resizeTV){
        if([[tableColumn identifier] isEqualToString:@"Name"]){
            if([[cell stringValue] isEqualToString:@"Cate"]){
               [table_view setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];

            }
      }
 }

}

使用此委托方法取消选择特定行

代码语言:javascript
复制
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
{
    if (row==7)
    {
        [table_view setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];

    }
    else
    {
        [table_view setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];

    }
    return YES;

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14216852

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档