Re: Newbie Q: How to implement multiple views occupying the same space?
Re: Newbie Q: How to implement multiple views occupying the same space?
- Subject: Re: Newbie Q: How to implement multiple views occupying the same space?
- From: Gore <email@hidden>
- Date: Fri, 18 Jan 2002 11:45:25 +0200
On Friday, January 18, 2002, at 10:12 , email@hidden wrote:
Hey,
Thanks for the tip and the quick response,
On Friday, January 18, 2002, at 02:22 AM, Gore wrote:
the best way to do this is to use a NSBox and setContentView:, in your
nib you shall have some NSViews in your instance window and have a
outlet connection to them. Then, when you get a action message from
the popup button, get the tag from the sender-id and put it in a
switch (), and then load the proper view into the box, like this
(remember to add a tag number to each menu item in IB):
- (IBAction)changeContentView:(id)sender
{
switch ( [sender tag] ) {
case 1:
[myBox setContentView: myView];
break;
...
}
}
Ok, but physically, in InterfaceBuilder, where do I put the NSViews in
the window?? Do I just drag them to some location outside the Window's
visible bounds so they can't be seen??
drag a NSView instance from the panel directly into the instance window
(where First Responder and File Owner are located), it will popup a
window that you can resize and so...that's the NSView, then drag your
content into the NSView window and save the project =), but remember to
add an outlet connection from your controller to the NSView instance so
that you can do the [myBox setContentView: myView]; call...where myBox
is your NSBox and myView is the NSView instance you have in your
instance window in IB.
there is a example showing this in the "Learning cocoa" book.
I'll have to get my hands on it.
Thanks again,
Here is the link to the example-archive file from the book:
http://examples.oreilly.com/learncocoa/examples.sit
download it and have fun!
email@hidden