0

I'm trying to use to a NSSplitView in my Xamarin.Mac Application. I need to add subviews programmatically for business reasons. It works fine, but there is a problem :

When I add a subview, it's added on the SplitView but on top of the precedent one : there's no separation between the subviews. They're superimposed. Here's how I do it :

        SplitView.AddSubview(View1);

        SplitView.AddSubview(View2);

My splitview is bound to the interface by an outlet type binding. I guess I have to do something manually with the separators but the documentation is really lacking for both Xamarin and Cocoa and I can't find why.

GlorfSf
  • 370
  • 1
  • 2
  • 12
  • 2
    `NSSplitView`: "A view that arranges two or more views in a linear stack running horizontally or vertically.". Do you want to add views to the splitview or to the views of the splitview? Are `addArrangedSubview:` and `insertArrangedSubview:atIndex:` what you're looking for? – Willeke Oct 18 '19 at 22:28
  • this I was looking for, indeed. Thank you, sorry if this was trivial. If you put it in the answer I'll validate it – GlorfSf Oct 21 '19 at 12:04

1 Answers1

1

From NSSplitView

A view that arranges two or more views in a linear stack running horizontally or vertically.

Subviews added with addSubview(_:) aren't arranged. NSSplitView provides methods to add and remove arranged subviews:

func addArrangedSubview(_ view: NSView)
func insertArrangedSubview(_ view: NSView, at index: Int)
func removeArrangedSubview(_ view: NSView)
Willeke
  • 14,578
  • 4
  • 19
  • 47