我的应用程序的联系页面中有一个拆分视图控制器..我无法隐藏页面中的导航栏..任何人都可以帮我隐藏navigationBar。我附上了我的代码
- (void)viewDidLoad
{
self.navigationController.navigationBarHidden = YES;
splitViewController.navigationController.navigationBarHidden = YES;
appdelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
[super viewDidLoad];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
[[VHeaderView sharedVHeaderView] viewWithCommonHeaderOnView1:self.view];
}
else
{
[[VHeaderView_iPad sharedVHeaderView_iPad] viewWithCommonHeaderOnView1:self.view];
}
[splitViewController.view setFrame:CGRectMake(0,48, 768, 1024)];
// [self.view removeFromSuperview];
//self.view.frame=CGRectMake(0,100, 768, 1024);
[self.view addSubview:splitViewController.view];
}
答案 0 :(得分:2)
试试这个。适合我。确保已分配导航控制器。
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
答案 1 :(得分:1)
- (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];
}
put this code in your .m file
如果你不想要动画效果,那就设置否。
答案 2 :(得分:0)
此方法只调用一次。
尝试将您的代码放入ViewWillAppear
-(void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
试试这段代码