在我的项目中,我在此视图中有loginviewcontroller,我在viewWillAppear方法中隐藏了navigationcontroller 如果登录成功,我有以下代码
-(void)gotoCheckinPage{
DashboardViewController *v = [[DashboardViewController alloc]
initWithNibName:@"DashboardViewController" bundle:nil];
UINavigationController *navCon = [[UINavigationController alloc]
initWithRootViewController:v];
[navCon.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar_bg.png"]
forBarMetrics:UIBarMetricsDefault];
[self presentViewController:navCon animated:YES completion:nil];
}
但在仪表板视图控制器导航控制器中未显示
这就是我在loginview中隐藏navigationcontroller的方式
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
如果我评论该行:
[self.navigationController setNavigationBarHidden:YES animated:animated];
没有问题,但希望在loginview中获取隐藏的navigationcontroller,然后在其他视图控制器中设置为活动
任何帮助?
答案 0 :(得分:1)
在您的视图中记下此代码。您要在其中显示导航
-(void)viewWillAppear:(BOOL)animated{
self.navigationController.navigationBarHidden = NO;
}
答案 1 :(得分:1)
您只需在LoginViewController中添加它:
-(void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = YES; // Where you want to hide it.
}
在DashboardViewController中:
-(void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = NO; // Where you want to show it.
}