Change Content of Custom View

For the moment, i have a window with :

  • left side : button for changing view
  • right side : a custom view (thecustomview)

I have got also many custom view (newView, C, .)

What i want to do is to click on a button on the first window (which call changeView) in order to replace the content of my thecustomview to newView


	property parent : class "NSObject"
	
	property theWindow : missing value
	property thecustomview : missing value
	property newView : missing value
	
	on changeView_(sender)
		tell thecustomview to setContentView_(newView)
	end changeView_

PS : i use no binding
All the custom view got the same size

You can’t use setContentview – that’s for things like windows, and implies a single view that completely fills it. You want to change views within a view. You will probably need to use removeFromSuperviewWithoutNeedingDisplay and addSubview:.

If all your views are the same size, it will probably be easier to to use a tabless NSTabView, with your button changing the selected tab.

Thanks for your answer.

In fact i tried to do that because i buy your book.

Using Tab seems to be a good idea, but how do do that ?
I saw in IB that i can hide tab, but how to aks tab to change with an other button

A little note to give your app a more pro look. For data representations to keep the user away from file handling like iPhoto, Mail, iTunes, Finder or Xcode you should use a source view. But when your application is mostly changing values like preference panes, preferences of application or a dvd burning app you should use tab view. If the views are a mixup of these two the most common way (not described by Apple) is still using a source view. The source view hierarchical depth should not be more than 2.

You button’s method would call selectTabViewItem: or one of the similar tab view methods.