Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add navigation controller programmatically?

In my app there is requirement that..I have 6 buttons in a nib, when I press any button a new nib will be loaded into the window according to the button pressed. problem is after loading the new nib If I want to come back to the previous nib (which is having all the buttons) how to add navigation controller?

what I am doing now is while loading the new nib when I pressed the button

objNewViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self.navigationController pushViewController:objNewViewController animated:YES];

but by this way im not able to load the nib, it's not performing any operation?

like image 591
CKT Avatar asked Jan 23 '26 04:01

CKT


1 Answers

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil]];

[self presentModalViewController:navigationController               animated:YES];
            [navigationController release];

And in NewViewController: USe this to dismiss and get back to previous view.

[[self navigationController] dismissModalViewControllerAnimated:YES];
like image 199
Manjunath Avatar answered Jan 25 '26 17:01

Manjunath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!