CALayers Lost After Switching Window's ContentView
CALayers Lost After Switching Window's ContentView
- Subject: CALayers Lost After Switching Window's ContentView
- From: Bridger Maxwell <email@hidden>
- Date: Sat, 14 Feb 2009 16:19:17 -0700
Hey,
I have an application which must switch in and out of full screen mode.
Going full screen is fine, but when I exit full-screen, my Core Animation
components disappear! Some debugging shows that the CALayer that backs the
view is still there and hasn't changed, but all of its sublayers have been
removed. I have no idea why this would happen though. To go full screen, I
make a new window and make it large and then switch the contentview from the
old window to the full screen window and vice-versa for returning to normal
mode. I don't see any reason why starting in normal mode and going full
screen works fine, but the other way around messes with my Core Animation
layers. Here is my go full screen code:
(regularWindow is an IBOutlet hooked up to a window in the application's nib
file. fullScreenWindow is just an NSWindow instance variable)
- (void)enterFullScreen {
if (!isFullScreen) {
// Capture the main display
if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display" );
}
// Put up a new window
if (!fullScreenWindow) {
fullScreenWindow = [[SCWindow alloc] initWithContentRect:[[NSScreen
mainScreen] frame]
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO screen:[NSScreen mainScreen]];
}
[fullScreenWindow setLevel:CGShieldingWindowLevel()];
[fullScreenWindow setContentView:fullScreenView];
[fullScreenWindow makeKeyAndOrderFront:nil];
[regularWindow orderOut:self];
isFullScreen = YES;
}
}
- (void)exitFullScreen {
if (isFullScreen) {
// Release the display(s)
if (CGDisplayRelease( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't release the display(s)!" );
}
[regularWindow setContentView:fullScreenView];
[regularWindow makeKeyAndOrderFront:nil];
[fullScreenWindow orderOut:self];
isFullScreen = NO;
}
}
Thank You,
Bridger Maxwell
_______________________________________________
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