0

So I have this layout. I need to load three views into it, the big view, which is part of the NSWindow. The sidebar view and the bottom view.

I almost managed to do it but cant put my finger onto how to complete the process. I want those views to load on app launch.

What I did was create a class which subclasses nsviewcontroller and create two other classes which subsclass the class i created just now.

then i went to main xib hooked up the NSViewcontroller but it dont load anything.

Slightly desperate here as I spent about 5 hours trying to figure this out. Any links to helpful tutorials would be nice. Or some advice how to do it... I almost got it working but my view want loading in the proper place.

My Layout

Dmitri K.
  • 197
  • 1
  • 13
  • You don't need to use a view controller, even though it's possible to do so. Why not just load the window from the XIB? Why wouldn't that work? – trojanfoe Dec 03 '15 at 20:27
  • The window is loaded from a .xib. But this window will have views that replace each other based on actions user takes. So the two custom views in my image need to be loaded from elsewhere, currently the required stuff is in a separate xib. So i need one xib to ask another xib to load in itself. – Dmitri K. Dec 04 '15 at 04:38

1 Answers1

0

You can maybe take a look on this. You problem seems easy to solve. http://www.raywenderlich.com/87004/getting-started-with-os-x-and-swift-tutorial-part-3

BrunoLoops
  • 554
  • 5
  • 20
  • Almost got it, the view started loading, apparently i forgot to initialize it, the only problem i have now is that it is loading on the bottom but aligne to left, instead of right, whats the easiest way to align it to bottom right corner? – Dmitri K. Dec 04 '15 at 05:35
  • Thanks for your comment. Your link was slightly off. Part 3 wasnt quite what worked for me. It was actually part 2. And i resolved it slightly differently. Basically what i did was create two nex xibs + header and implementation fiels for them. Set file owners in those xibs to the relevant .h file names. Then went into main .xib created NSViewcontrollers and bound them in the third tab on right of xcode to the televant xibs. Then in code initialised the view controllers and told the custom view to load the viewcontrollerview. – Dmitri K. Dec 04 '15 at 11:31
  • This line basically: [self.bottomBar addSubview:self.myViewController.view]; – Dmitri K. Dec 04 '15 at 11:32
  • I follow all the tutorial and was really good to understand how work with xibs and views. I don't know if its good to add a subview to the bottomBar, I suggest to use constraints to set the desired position and size – BrunoLoops Dec 08 '15 at 16:13