以模态方式呈现的表视图没有导航栏

时间:2012-10-19 21:48:43

标签: iphone objective-c ios cocos2d-iphone ios6

当我以模态方式呈现视图控制器时:

  

//以模态方式显示导航控制器。

     

[self presentModalViewController:theNavController animated:YES];

导航栏被弹出的视图遮住了! 如何让导航栏不被遮盖?

提前致谢!

2 个答案:

答案 0 :(得分:3)

答案可在iPhone: Show modal UITableViewController with Navigation bar找到 和 UINavigationBar refuses to show in Modal View Controller

您需要将UIViewController包裹在UINavigationController中,然后展示导航控制器:

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]; 

答案 1 :(得分:1)

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewContorller:someViewController];
[self presentModalViewController:navController animated:YES];