1

我的代码中有以下AppDelegate代码UINavigationBar

NSArray *viewsArray;

ToolsViewController *toolsnavigation = [[ToolsViewController alloc] initWithNibName:@"ToolsViewController" bundle:nil];
toolsnavigation.tabBarItem.image = [UIImage imageNamed:@"setting_image.png"];
[toolsnavigation setTitle:@"Tools"];
UINavigationController *nav0 = [[UINavigationController alloc] initWithRootViewController:toolsnavigation];

MyrideViewController *myridenavigation = [[MyrideViewController alloc] initWithNibName:@"MyrideViewController" bundle:nil];
myridenavigation.tabBarItem.image = [UIImage imageNamed:@"bottom_nav_image_2.png"];
[myridenavigation setTitle:@"My Ride"];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:myridenavigation];

NewsViewController *newsnavigation = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
newsnavigation.tabBarItem.image = [UIImage imageNamed:@"bottom_nav_image_3.png"];
[newsnavigation setTitle:@"News"];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:newsnavigation];

CoolViewController *coolnavigation = [[CoolViewController alloc] initWithNibName:@"CoolViewController" bundle:nil];
coolnavigation.tabBarItem.image = [UIImage imageNamed:@"bottom_nav_image_4.png"];
[coolnavigation setTitle:@"Cool"];
UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:coolnavigation];

AccidentViewController *accidentnavigation = [[AccidentViewController alloc] initWithNibName:@"AccidentViewController" bundle:nil];
accidentnavigation.tabBarItem.image = [UIImage imageNamed:@"bottom_nav_image_5.png"];
[accidentnavigation setTitle:@"Accident"];
UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:accidentnavigation];

viewsArray = [NSArray arrayWithObjects:nav0,nav1,nav2,nav3,nav4, nil];
UITabBarController *tabbarController = [[UITabBarController alloc] init];
tabbarController.view.frame = CGRectMake(0,0,320,460);

[tabbarController setViewControllers:viewsArray];

self.window.rootViewController = tabbarController;

这样,UINavigationBar 就会出现在每个页面上。我希望它出现在几页之后,就像用户登录后,导航栏就会出现。我当前的代码不会发生这种情况。我怎样才能解决这个问题?

这也是登录页面上导航栏的屏幕截图

4

2 回答 2

0

在您希望隐藏的任何地方使用导航栏的隐藏属性

controllerObject.navigationController.navigationBar.hidden = YES;

在你的情况下添加

nav0.navigationBar.hidden = YES;

行后

UINavigationController *nav0 = [[UINavigationController alloc] initWithRootViewController:toolsnavigation];
于 2012-10-09T05:44:50.330 回答
0

在您的LoginView 中 viewDidLoad

[self.navigationController.navigationBar setHidden:YES];  

然后在其他视图中

[self.navigationController.navigationBar setHidden:NO];
于 2012-10-09T05:48:42.953 回答