2

您好,我需要在 Maya、3ds max、Blender 或其他类似的建模工具中实现四个视图拆分器。我在编辑器的 Mac 端使用 NSSplitView,我需要知道用户何时拖动一个窗格以同步另一个窗格。
有没有办法从一个 NSSplitView 获取新大小并将另一个视图同步到它?我在此编辑器的 C# 版本中有适用于 Windows 窗体的工作代码,但我不知道如何在 Mac 上执行此操作。完整的源代码位于http://github.com/filipkunc/opengl-editor-cocoa

非常感谢。

4

1 回答 1

4

我用这段代码修复了它:

- (void)splitViewDidResizeSubviews:(NSNotification *)notification
{
    NSSplitView *splitView = (NSSplitView *)[notification object];
    NSView *topSubview0 = (NSView *)[[topSplit subviews] objectAtIndex:0];
    NSView *topSubview1 = (NSView *)[[topSplit subviews] objectAtIndex:1];

    NSView *bottomSubview0 = (NSView *)[[bottomSplit subviews] objectAtIndex:0];
    NSView *bottomSubview1 = (NSView *)[[bottomSplit subviews] objectAtIndex:1];

    if (fabsf([bottomSubview0 frame].size.width - [topSubview0 frame].size.width) >= 1.0f)
    {
        if (splitView == topSplit)
        {
            NSLog(@"topSplit");
            [bottomSubview0 setFrame:[topSubview0 frame]];
            [bottomSubview1 setFrame:[topSubview1 frame]];
        }
        else
        {
            NSLog(@"bottomSplit");
            [topSubview0 setFrame:[bottomSubview0 frame]];
            [topSubview1 setFrame:[bottomSubview1 frame]];
        }
    }
}
于 2009-12-26T20:45:45.840 回答