http://www.irovr.com/stackOverflow/overlap.png
- (void)viewDidLoad {
[super viewDidLoad];
[self setWantsFullScreenLayout:YES];
[mainScrollView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onMainScrollTap:)]];
}
- (void)onMainScrollTap:(id)sender {
if(self.navigationController.navigationBar.hidden){
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setToolbarHidden:NO animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}else{
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:YES animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.toolbar.translucent = YES;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:YES animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
self.navigationController.navigationBar.translucent = NO;
self.navigationController.toolbar.translucent = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setToolbarHidden:YES animated:NO];
}
It seems that hiding the status bar and navigation bar at the same time causes this problem. I was able to resolve it by hiding/showing the navigation bar with performSelector:withObject:afterDelay
, even with a delay of 0
Using "performSelector" will work.
However, some may find it easier to add the following to "viewWillDisappear" even if there is already a statement that unhides the navigation bar.
[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController setNavigationBarHidden:NO animated:NO];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With