MrShoot
MrShoot

Reputation: 863

Do I need to implement a Navigation controller in order to add views from other controllers?

When user taps on a button, I am displaying a whole new view (administration purposes)

AdminViewController *adminView = [[AdminViewController alloc]initWithNibName:@"AdminView" bundle:nil];
        [self.view addSubview:adminView.view];
        [adminView release];

In the view that I am pushing I have an IBAction with a close button. Basically, when I hit the close button, I want to destroy that second view and go back to my original one.

I can't use self.view removeFromSuperview because that will pretty much remove everything I have in the window. What do you guys think I need to do?

Upvotes: 0

Views: 69

Answers (1)

Matthew Gillingham
Matthew Gillingham

Reputation: 3429

It sounds like this setup is an ideal candidate for

AdminViewController *adminView = [[AdminViewController alloc]initWithNibName:@"AdminView" bundle:nil];
[self presentModalViewController:adminView animated:YES];
[adminView release];

when the close button is pressed, you can do

[self dismissModalViewControllerAnimated:YES];

on either view controller to make it disappear.

Upvotes: 1

Related Questions