objective-c - 如何从 cocoa 的 super View 中删除imageview?

标签 objective-c macos cocoa nstableviewcell

当我重新加载单元格的NSTableView ImageView 时被覆盖。如何从 cocoa 的 super View 中删除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];

看我的截图,图像是重叠的。我怎样才能在 cocoa 中阻止它?

最佳答案

如果这是一个 NSTableView,请尝试刷新“已编辑”单元格或整个表格以重绘

编辑的 NSTABLEVIEW

关于objective-c - 如何从 cocoa 的 super View 中删除imageview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34991583/

相关文章:

objective-c - 如何在启动主应用程序时启动 Finder Sync Extension?

objective-c - 如何将 NSDecimalNumber 转换为 NSNumber

iphone - UIStringDrawing 方法在 iOS 6 中似乎不是线程安全的

objective-c - 关于 UINavigationController 的思考

c++ - 定时器挂起主线程

objective-c - 以编程方式更改停靠标题

c - 找不到 Eclipse mac osx : Launch failed, 二进制文件

mysql - 错误! MariaDB 服务器进程 #{pid} 未运行

objective-c - 变量不是NSAttributedString?

ios - 键值观察的新手;为什么我无法在我的 AppDelegate 中监控 int 的值?