Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding UINavigationController to existing UIViewController

How do I add an existing UIViewController (which is presented using presentModalViewController) to a UINavigationController?

When user tap on button, a new copy of my detail view need to be pushed. (In other words, pushViewController displaying pushViewController, modally, in a UINavigationController).

Easiest way to enable this functionality?

like image 440
marko Avatar asked Feb 10 '11 13:02

marko


1 Answers

how do you create your modal viewcontroller? Just wrap the controller into a UINavigationController

Let's assume your modal code is like this:

MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:@"MyExample" bundle:nil] autorelease];
[self presentModalViewController:vc animated:YES];

Then change it into something like this:

MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:@"MyExample" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
[self presentModalViewController:navController animated:YES];
like image 157
Matthias Bauch Avatar answered Oct 14 '22 08:10

Matthias Bauch