Frage

Why NSImage drawn flipped in the NSCell of NSTableView. And how proper fix that behavior. I returns image from the data source method:

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
return [NSImage imageNamed: @"test.png"];
}

As workaround I tried:

[NSImage setFlipped:NO];

All is ok but as documentation says that it deprecated method

osx 10.7-10.9

War es hilfreich?

Lösung 2

I solved problem by replacing code of getting image from:

return [NSImage imageNamed: @"test.png"];

to:

NSData * imageData = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForImageResource: test.png]];
return [[NSImage alloc] initWithDataIgnoringOrientation:imageData];

I don't know reason of that behavior and documentation nothing says me. But I'll happy if you explain me.

Andere Tipps

Here is some info I just came across.

Basically according to the link you have to:

  1. Drag an image cell in the column you wish to show the image

  2. Return an NSImageCell initialised with your image, like so:

    - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row 
    {
        NSCell *imageCell = [[NSCell alloc] initImageCell:[NSImage imageNamed: @"test.png"]];
        return imageCell;
    }
    
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top