How to add a navigation controller programmatically?

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

what i am doing now while loading a new pen when i clicked

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

but this way I can’t load the pen, it does not perform any operations?

+3
source share
2 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 fire and return to the previous view.

[[self navigationController] dismissModalViewControllerAnimated:YES];
+6
source

Xcode . , . , , , AnotherViewController in -tableView:didSelectRowAtIndexPath:.

0

Source: https://habr.com/ru/post/1736268/


All Articles