2

我在 NSOpenGLView 上显示了一个 NSView。我正在使用“setWantsLayer:YES”来强制 NSView 出现在 opengl 上下文中。但是当我最小化窗口并再次将其最小化时,NSView 不再超过 NSOpenGLView。

有没有办法防止这种行为?

4

1 回答 1

2

好的,我已经找到了解决这个问题的方法。可能不是最好的,但可以解决问题。

首先,我在 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 前面。

于 2014-06-11T12:51:15.523 回答