当页面隐藏navigationBar[self.navigationController setNavigationBarHidden:YES];
期望整个view填充window的时候,会发现存在scrollView的情况下,顶部会自动留出stateView高度的距离。例如,下方是tableView的情况:
总的解决方案:
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
也有另一种解决思路,就是在顶部增加一个view(非scrollView),下方的scrollView不会自动留出空隙
view填充顶部.png
问题:手势左滑返回上一级,navigationBar出现异常
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES ];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO ];
}
具体表示:
navigationBar异常.gif
改为
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
navigationBar正常.gif
网友评论