amrit_neo
amrit_neo

Reputation: 1759

Swapping Views in Mac application

I am creating an app in which I am able to swap the views using the top buttons named "1"and "2"....using them i can swap the views in the box. I am using the view controller. but the problem is that I want to swap my views using the buttons inside the view. I want to swap the view when I press the button inside one view. I have tried all the thing but not working. [box setContentView:v]; [box addSubview:v]; Please help enter image description here

Upvotes: 1

Views: 441

Answers (2)

ShinuShajahan
ShinuShajahan

Reputation: 1296

For button '1' action...

//For opening the second nib on first button click
NSWindowController * second=[[NSWindowController alloc] initWithWindowNibName:@"secondNIB"];
[second showWindow:self];

//For closing the first nib, optional
//firstWindow is NSWindow
[firstWindow orderOut:nil];

For button '2' action...

//For opening the first nib on second button click
NSWindowController * first=[[NSWindowController alloc] initWithWindowNibName:@"firstNIB"];
[first showWindow:self];

//For closing the second nib, optional
//secondWindow is NSWindow
[secondWindow orderOut:nil];

Upvotes: 0

BenL0
BenL0

Reputation: 287

Take a look at [NSView replaceSubview: with:];

Upvotes: 1

Related Questions