Eslam Hamdy
Eslam Hamdy

Reputation: 7386

present navigation controller from another navigation controller

I have a UIViewController that's embedded inside a UINavigationController and I want to present another navigation controller from inside the UIViewController of the first navigation controller.

The problem is that when I present and dismiss that UINavigationController the back button of the first navigation controller disappears, I want to present navCtrl and when I dismiss it the back button of the first UINavigationController remains

VendorsViewController* vendorsVC = [[VendorsViewController alloc]initWithNibName:@"VendorsViewController" bundle:nil];
NSMutableArray* vendorListArray = [NSMutableArray arrayWithArray:self.cachedVendorList.crossSearchResults];
[vendorListArray insertObject:@"All Vendors" atIndex:0];
UINavigationController* navCtrl = [[UINavigationController alloc]initWithRootViewController:vendorsVC];
[self.navigationController presentModalViewController:navCtrl animated:YES];

Upvotes: 2

Views: 1407

Answers (1)

Michael
Michael

Reputation: 6899

Create your second UINavigationController and set its rootViewController as your UIViewController. Then on your UIViewController set a button/control with an action to dismiss your UIViewController.

- (IBAction)dismiss:(id)sender
{
    [self.presentingViewController dismissViewControllerAnimated:YES
                                                      completion:nil];
}

Upvotes: 3

Related Questions