在NSSplitView中使用NSOpenGLView

4
当我将NSOpenglView放入NSSplitView中时,拖动分隔器会出现问题。OpenGLView和SplitView在异步调整大小。我在苹果邮件列表线程中找到了一个解决方案,链接如下:http://developer.apple.com/mac/library/samplecode/GLChildWindowDemo/Introduction/Intro.html 我使用了一些Carbon调用来解决这个问题。但是现在我在发布模式下遇到了链接错误。
所以我的两个问题是:是否有任何Cocoa方法来解决拆分器-GL问题?如果没有,如何在发布模式下解决碳链接器错误?

可能是过时的Carbon包装器导致了链接错误。另一方面,我读到OpenGL和UIKit元素之间存在兼容性问题...我建议尽可能使用单个框架。 - Rigo Vides
这里没有UIKit,这是一个Cocoa/Mac的问题。 - Rob Keniger
1个回答

4

我找到了答案。

正确的方法是在您的MYWindow:NSWindow中实现这些方法。

BOOL needsEnableUpdate;

-(void)disableUpdatesUntilFlush
{
    if(!needsEnableUpdate)
        NSDisableScreenUpdates();
    needsEnableUpdate = YES;
}

-(void)flushWindow
{
    [super flushWindow];
    if(needsEnableUpdate)
    {
        needsEnableUpdate = NO;
        NSEnableScreenUpdates();
    }
}

在 NSSplitterView 代理中实现

#pragma mark NSSplitView Delegate
-(void)splitViewWillResizeSubviews:(NSNotification *)notification
{
    [window disableUpdatesUntilFlush];
}

我的问题是我尝试使用Carbon调用:
DisableScreenUpdates();
EnableScreenUpdates();

而不是可可的:

NSDisableScreenUpdates();
NSEnableScreenUpdates();

只是想说谢谢谢谢谢谢。你太棒了。 - Morgan
为了清晰起见,我会写成:-(void)disableUpdatesUntilFlush { if(!needsEnableUpdate) { NSDisableScreenUpdates(); needsEnableUpdate = YES; } } - Ricardo Sanchez-Saez

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接