Ramuel
Ramuel

Reputation: 59

adding an UINavigationController to a UIControllerView

i was searching this whole afternoon in hope of solution but i didn't manage to find anything helping me solve the problem.

The problem is, i have no intention of using UINavigationController until a button gets taped, and after that i would like to present view controller containing a navigationcontroller, or reverse, modally. in my search i came across this solution:

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

which i then used it in my code and found out it is not working, to make sure i started a practice project from viewbased project templet and added this to the first view controller

- (IBAction) buttonGotPreseed{
testino *testController = [[testino alloc] initWithNibName:@"testino" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:testController];
testController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:testController animated:YES];
[nav release];
[testController release];

}

didn't work also, im not seeing the navigation bar up there

any help would be greatly appreciated

Upvotes: 1

Views: 422

Answers (1)

Morgan Harris
Morgan Harris

Reputation: 2619

You're pushing the root view controller, not the navigation controller itself. Line 5 should be:

[self presentModalViewController:nav animated:YES];

Upvotes: 2

Related Questions