0
votes

I have a XIB based Cocoa OS X App. In my main window I wish to draw one or more instances of a custom view.

My XIB file has the main window, and I dragged out a Custom View too. I have subclassed NSView and set the class type for the custom view to my new subclass (I called it ChannelControlsView).

I have dragged a Custom View onto the main winodw and set it's class type also to ChannelControlsView as you can see in the attached image.

enter image description here

However when my main window is drawn, the custom view does not appear. What mistake have I made? This is pretty much how I do it on iOS and it works there, so I guess there are some extra steps for OS X apps?

1

1 Answers

0
votes

The view that appears at the bottom of the provided screenshot (with the controls on it) is not a part of the windows view hierarchy, this is why it isn't appearing when you load the window.

To make it a part of the hierarchy:

  1. Select it using the Interface Builder dock (the part on the left-hand side of the screenshot),
  2. Drag it (still in the dock) to just below Mov View and just above Channel Controls View.
  3. Delete the Channel Controls View that is already on the window (the one colored pink in the above screenshot)

Your hierarchy should look the same Window >> Mov View >> Channel Controls View, but you shouldn't have any floating views (i.e. views on the canvas, but not on the Window).