0
votes

When using the modalViewController, I found that that only way to keep a title bar and buttons on the screen that I jump to was to create a navigation controller and set the modalView screen as the rootView of the navigation controller (as below).

userNameViewController = [[UserNameViewController alloc] init];

UINavigationController *cntrol = [[UINavigationController alloc]          initWithRootViewController:userNameViewController];

[self.navigationController presentModalViewController:cntrol animated:YES];

[userNameViewController release];
[cntrol release];

Why can't I simply this by using the original viewController as the modalView (as below)?

userNameViewController = [[UserNameViewController alloc] init]; [self presentModalViewController:userNameViewController animated:YES];

1
If your aren't pushing any viewcontrollers in your UserNameViewController you can. But you will have to add the UINavigationBar in the NIB. also you need to added any button you want in the Navigation directly in the NIB.rckoenes

1 Answers

0
votes

Because the navigation bar you usually see belongs to the navigation controller, not to its children view controllers.

You could create your own navigation bar and add it to your controller's view. However, it would require some relayout (and that's probably why it's easier to just recreate a navigation controller).