1

When I reload the NSTableView imageview of cell is overwrite. How to remove imageview from superview in cocoa?

enter image description here

I have tried below code:

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];

See my screenshot, the image is overlapped. How can I stop it in cocoa?

Fabio Berger
  • 1,921
  • 2
  • 24
  • 29
princ___y
  • 1,089
  • 1
  • 9
  • 27
  • Do you want to replace tabIconImageview? Shouldn't you assign tabIconImageview1 to tabIconImageview somewhere? Can't you just replace the image in tabIconImageview? – Willeke Jan 25 '16 at 12:00

1 Answers1

0

If this is a NSTableView, try to refresh "edited" cells or entire table to redraw

EDITED NSTABLEVIEW

nigelman
  • 153
  • 8