0

When I present a view controller modally:

// Display the nav controller modally.

[self presentModalViewController:theNavController animated:YES];

The navigation bar is covered up the view the pops up! How can I get the navigation bar to not get covered up??

Thanks in advance!

Community
  • 1
  • 1
waylonion
  • 6,866
  • 8
  • 51
  • 92
  • Position the view that is covering it below the navigation bar. It covers it because the views share the same superview and probably both have a y-origin of 0. – Matt Oct 19 '12 at 22:08
  • Either add a navigationBar or wrap the presented controller in a `UINavigationController` – Paul.s Oct 19 '12 at 22:08
  • Can you explain with code? Thanks! – waylonion Oct 19 '12 at 22:10

2 Answers2

3

The answers can be found at iPhone: Show modal UITableViewController with Navigation bar and UINavigationBar refuses to show in Modal View Controller!

You need to wrap the UIViewController in a UINavigationController, and then present the navigation controller:

AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:@"AccountView" bundle:nil]; 
... 
// Initialize properties of accountViewController 
... 
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController]; 
[self.navigationController presentModalViewController:navController animated:YES]; 
[navController release]; 
[accountViewController release]; 
Community
  • 1
  • 1
waylonion
  • 6,866
  • 8
  • 51
  • 92
1
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewContorller:someViewController];
[self presentModalViewController:navController animated:YES];
aryaxt
  • 76,198
  • 92
  • 293
  • 442