Create NSSplitView + subview programmatically

前端 未结 1 457

I am trying to create a horizontal NSSplitView programmatically and to add it 2 subviews. Unfortunately, if I have no issue to create the splitview, I do not know h

相关标签:
1条回答
  • 2021-02-10 11:40

    You add panes to a split view the same way you add subviews to any view. Each of the split view's subviews will get its own pane. You can use the adjustSubviews method to automatically resize the views so that each pane is the same size.

    This example code will create a split view which fills its window and has 3 text views split vertically.

    NSSplitView *splitView = [[NSSplitView alloc] initWithFrame:[[theWindow contentView] bounds]];
    NSTextView *textView1 = [NSTextView new];
    NSTextView *textView2 = [NSTextView new];
    NSTextView *textView3 = [NSTextView new];
    [splitView addSubview:textView1];
    [splitView addSubview:textView2];
    [splitView addSubview:textView3];
    [splitView adjustSubviews];
    [[theWindow contentView] addSubview:splitView];
    [textView3 release];
    [textView2 release];
    [textView1 release];
    [splitView release];
    
    0 讨论(0)
提交回复
热议问题