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
Here is some info I just came across.
Basically according to the link you have to:
Drag an image cell in the column you wish to show the image
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; }
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.