【发布时间】:2014-06-11 20:51:15
【问题描述】:
我在 NSOpenGLView 上显示了一个 NSView。我正在使用“setWantsLayer:YES”来强制 NSView 出现在 opengl 上下文中。但是当我最小化窗口并再次将其最小化时,NSView 不再超过 NSOpenGLView。
有没有办法防止这种行为?
【问题讨论】:
标签: macos nsopenglview
我在 NSOpenGLView 上显示了一个 NSView。我正在使用“setWantsLayer:YES”来强制 NSView 出现在 opengl 上下文中。但是当我最小化窗口并再次将其最小化时,NSView 不再超过 NSOpenGLView。
有没有办法防止这种行为?
【问题讨论】:
标签: macos nsopenglview
好的,我已经找到了解决此问题的方法。可能不是最好的,但可以解决问题。
首先,我在 appDelegate 类中声明了一个通知器:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowDidDeminiaturize:)
name:NSWindowDidDeminiaturizeNotification object:nil];
此通知程序检测窗口最小化事件。然后,在回调函数中,我这样做:
- (void)windowDidDeminiaturize:(NSNotification *)notification
{
[view_PlaybackView setWantsLayer:NO];
[view_PlaybackView setWantsLayer:YES];
}
视图再次显示在 NSOpenGLView 前面。
【讨论】: