0
votes

I have 4 NSViews (A,B,C,D) inside a NSWindow contentView, one over another (like a stack of NSViews). I added the views using IB and connected them with a File Owner. Every view has a NSViewController. I want to order the views in this way |A|B|C|D|. But after loading all the views this is what I have: |A|B|D|C|. I want to reorder NSView C in its rightful place.

I tried using addSubview:positioned:relativeTo: [[self.window contentView] addSubview:viewC positioned: NSWindowBelow relativeTo:viewD];

But now the NSView never shows.

How do I change viewC order?

Thanks!

1

1 Answers

0
votes

You control the relative "vertical" (front/back) placement of views in a xib by altering their order in the panel on the left hand side:

panel in Interface Builder

The way that I have organized the different views here, "View D" is at the front, "View C" is behind it, "View B" behind "View C", and "View A" behind them all. Here's the result:

ordered view demo

For this demo, I've made each of the four views layer-hosting and set the background colors of the views so that

  • View A is red
  • View B is green
  • View C is blue
  • View D is black

As you can see, the bottommost view, View D, is at the fore, View C behind it, and so on.