I have an application which has a layout similar to iTunes. The main window is an NSSplitView.
Depending on what the user selects in the left column, I need to show a different view. For example, in itunes if you click on "Music" you see a list of songs in a table, if you click on "TV Shows" I see a white screen with some text on it.
Been trying to work this out for ages, any pointers in the right direction would be very handy!
In the right-hand pane of your NSSplitView
you could place a tab-less NSTabView
. Each tab of the view could contain one of the views you want to display. Then, in your outline view's delegate, just ask the tab view to display the appropriate view when a particular item is selected.
This is really a job for NSViewController. Using that means you can put each view into a separate nib file and then swap them in and out as needed. When you need to swap the views you can do something like this (assuming you have an NSBox in the right hand pane of the NSSplitView)
NSView *musicView = [musicViewController view];
[rightPaneBox setContentView:musicView];
Edit for a fuller example:
If you have, for example, a Music view and a TV view. You'd create two new nib files, say MusicView.nib and TVView.nib and design your views in those. Then you'd create two subclasses of NSViewController, MusicViewController and TVViewController. In the init method for each of those you'd call [super initWithNib:@"MusicView.nib" bundle:nil].
then in your methods that select the new view, call [musicViewController view] to get a view to place into the right hand side of the NSSplitView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With