Re: One window, multiple nibs?
Re: One window, multiple nibs?
- Subject: Re: One window, multiple nibs?
- From: "Jim Thomason" <email@hidden>
- Date: Mon, 3 Dec 2007 06:40:12 -0600
It's fairly straightforward, assuming I'm remembering enough of the
details after just getting up.
First of all, set up a controller that has outlets for all of the nibs
you want Let's call it "ViewController" Instantiate it somehow so it
exists early on.
Create each of your alternate view nibs (ViewA, ViewB, ViewC) and set
the File's owner to ViewController. Create a new view in each nib and
wire it up to the appropriate outlet (viewA, viewB, viewC, etc.). Note
that you'll only wire up one of those views per nib file so your
object's gonna have the indicator on it that connections are missing.
This is okay.
ViewController needs a method to switch views. Here's a stub method
with other assumed stuff omitted.
-(void) selectView:(id) aView {
//if the view isn't loaded
if (! [self isLoaded:aView]) {
[NSBundle loadNibNamed:aView valueForKey:@"nib"] owner:self ];
[self setLoaded:aView]; //note! this assumes that the nib loading
always works
}
//note - this doesn't adjust the size of the window
[[self window] setContentView:[self viewForName:aView]];
}
Fill in your own isLoaded, setLoaded, and viewForName methods.
viewForName takes a name ("ViewA") and returns a view ([self viewA]).
Don't forget to automatically select whichever one of those views
should pop up at launch.
-Jim....
On 12/3/07, Tim Perrett <email@hidden> wrote:
> Hey All
>
> I appreciate this question must come up all the time, but im
> struggling to find an answer to it (with an example of code too)
>
> I want to have a single window, but break parts out into separate nib
> files to keep things tidy. I presume that I just drop down a custom
> view in IB, then I need to link it up to the controller in which is
> calls the nib somehow?
>
> If someone could perhaps drop a small sample onto the list that would
> be awesome, or link to somewhere on the net where there is such a
> thing. People seem to talk about the powergurdian MDI example, but
> there site seems to no longer be there?
>
> Any help would be much appreciated
>
> Cheers
>
> Tim
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden