Re: Question about "swappable" views
Re: Question about "swappable" views
- Subject: Re: Question about "swappable" views
- From: Mason Mark <email@hidden>
- Date: Tue, 30 Oct 2001 17:06:31 -0800
--On Tuesday, October 30, 2001 4:32 PM -0600 Stuart Stanley
<email@hidden> wrote:
What do you mean "lower" than a full window?? You can drag a custom view
from the palette into the document window and use that. Is that what you
mean??
Mmmm, but that only gives me _one_ view to use. I need to create a
set of "detached" custom views that I can someone make active in the
space to the right of the outline view. I was hoping there was a way
in IB to make a set of NIBs, one for each column that can be clicked
in, but I don't want the item to be a window (just a custom view).
Here's one way to do it:
1) In IB, drag a "Custom View" from the palette into your app's window.
Just leave this view as an NSView (which is what it will be by default),
and don't put anything in it.
2) Drag another "Custom View" from the palette into your nib document
window (the window which shows the File's Owner, First Responder, etc).
This is what Vince was talking about.
3) Double click this new custom view, fill it up with whatever UI stuff you
need for one of your "swappable" views.
4) For whatever object in your nib file is serving as controller (e.g. your
window controller or some other controller object instantiated in the nib),
make sure that it has an outlet for each custom view you need. Ctrl-drag a
connection from the controller to the new custom view you just created and
hook it up to the appropriate outlet.
5) Repeat steps 2-4 for each custom view you need. Then you can define a
single method to switch among the custom views, which does something like
[theSuperview replaceSubview:currentCustomView with:newCustomView];
That way, you can have more than one custom view in your single nib file.
(If your custom views were numerous or complex, it might be desirable to
separate them into multiple nib files that get loaded on demand, but your
scenario seems simple.)
--
Mason