如何从可可中的超级视图中删除imageview?

时间:2016-01-25 11:33:02

标签: objective-c macos cocoa nstableviewcell

当我重新加载时,NSTableView单元格的图像视图被覆盖。如何从可可中的superview中删除imageview?

enter image description here

我试过下面的代码:

NSImageView *tabIconImageview1=[[NSImageView alloc]initWithFrame:NSMakeRect(45, 12, 40, 40)];

[tabIconImageview removeFromSuperviewWithoutNeedingDisplay];
[tabIconImageview removeFromSuperview];
if ([strFilenames hasSuffix:@"."])
{
    [tabIconImageview1 setImage:[NSImage imageNamed:@"fileicon"]];
    //tabIconImageview1.image=[NSImage imageNamed:@"fileicon"];
}
else if ([strFilenames hasSuffix:@".exe"])
{
    [tabIconImageview1 setImage:[NSImage imageNamed:@"exeicon"]];
}
else if ([strFilenames hasSuffix:@"png"])
{
    [tabIconImageview1 setImage:[NSImage imageNamed:@"imageicon"]];
}
else if ([strFilenames hasSuffix:@".zip"])
{
    [tabIconImageview1 setImage:[NSImage imageNamed:@"zipicon"]];
}
else //if ([strFilenames hasSuffix:@"."])
{
    [tabIconImageview1 setImage:[NSImage imageNamed:@"foldericon"]];
}

[cellView addSubview:tabIconImageview1];

查看我的截图,图像重叠。我怎么能用可可来阻止它?

1 个答案:

答案 0 :(得分:0)

如果这是NSTableView,请尝试刷新"编辑"要重绘的单元格或整个表格

编辑NSTABLEVIEW