JBJr
JBJr

Reputation: 109

NSTabViewItem image doesn't display when changed

Somewhere in macOS (perhaps in Mojave), a programmatic change of the image in an NSTabViewItem doesn't refresh the tab's display (although it does actually replace the image property) to show the new image. In prior versions of macOS, replacing the image caused redisplay of the tab with the new image. Now however, only taking the window containing the NSTabView out of focus, or clicking the tab will redraw the new image. Sending setNeedsDisplay: to the NSTabView or any of its containing views does nothing.

Worked around this (in Mojave) by removing the NSTabViewItem from its NSTabView, changing the image, then inserting the NSTabViewItem back at its original index position, but this doesn't seem right. Anyone encountered this or a published reason for this behavior?

Upvotes: 1

Views: 217

Answers (1)

stephen liu
stephen liu

Reputation: 36

try this to force the NSTabViewItem to redisplay the label:

NSString *originLable = [self.label copy];
NSString *newLabel = [NSString stringWithFormat:@"%@ ",originLable];
[self setLabel:newLabel];
[self setLabel:originLable];

Upvotes: 0

Related Questions