Changing tab in NSTabView with wantsLayer and Garbage collection problem.
Changing tab in NSTabView with wantsLayer and Garbage collection problem.
- Subject: Changing tab in NSTabView with wantsLayer and Garbage collection problem.
- From: Mathieu Coursolle <email@hidden>
- Date: Fri, 7 Mar 2008 16:01:45 -0500
Hi Cocoa dev,
I would like to use core animation in an application, so I am
investigation on how
to use the wantsLayer property of an NSView, but I got confused with
some behavior so far...
I created a simple window, in which there is a tab view. In the first
tab, I added a custom view, and in the second tab I added some basic
controls (table view, button, etc.).
My custom view sets wantsLayer to YES in awakeFromNib, and then just
fills with green in drawRect, so no complex drawing. A timer is used
to change the green intensity to know when drawRect is called.
However, if wantsLayer is YES, and Garbage collection is set to
supported, then changing tab from my green view to the other tab does
not hide the green view right away. The second tab appears, but my
custom views stays visible on top of the second tab for 1 second or 2,
then goes away by itself.
If wantsLayer is NO, or if garbage collection is disable, everything
is ok.
Am I missing something here?
Here is my custom view code in case some of you might find a problem...
Thanks!
Mathieu
@implementation MyView
@synthesize timer;
@synthesize colorValue;
- (void)timerDidFired:(NSTimer *)timer
{
double oldValue = [self colorValue];
oldValue += 0.01;
if (oldValue > 1)
oldValue = 0;
[self setColorValue:oldValue];
[self setNeedsDisplay:YES];
}
- (void)awakeFromNib
{
[self setWantsLayer:YES];
NSTimer* aTimer = [NSTimer scheduledTimerWithTimeInterval:0.01
target:self selector:@selector(timerDidFired:) userInfo:nil
repeats:YES];
[self setTimer:aTimer];
}
- (void)drawRect:(NSRect)rect
{
[[NSColor colorWithCalibratedRed:0.0 green:[self colorValue] blue:0.0
alpha:1.0] set];
[NSBezierPath fillRect:[self bounds]];
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden