最近遇到一个坑,跟大家分享一下。
1. 按照下面这么写,切换页面显示隐藏导航栏时,上方会出现黑块。
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO;
}
2. 按照下面这么写,切换页面显示隐藏导航栏时,页面会导航栏下方滑上去。
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YESanimated:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
3. 上面两种写法都有问题,下面的写法才是正确的,哦~,反正解决了当前的问题,以后会不会有问题我也不知道,嘿嘿嘿~
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
网友评论