Click Gesture to hide the navigation bar, tab bar, and status bar.

I am trying to implement a binding gesture on my web view in order to hide / show the navigation bar, tab bar and status bar. I have a hide / show navigation bar working fine and I can hide the status bar but not get it to show a backup. The tab bar items are hidden, but the bar is still there. Can anyone help with this?

- (void)toggleBars:(UITapGestureRecognizer *)gesture { [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; BOOL statusBarHidden = YES; BOOL barsHidden = self.navigationController.navigationBar.hidden; [self.navigationController setNavigationBarHidden:!barsHidden animated:YES]; BOOL tabBarHidden = self.tabBarController.tabBar.hidden; [self.tabBarController.tabBar setHidden:!tabBarHidden]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showMenu)]; self.navigationItem.rightBarButtonItem = systemAction; UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toggleBars:)]; [webView addGestureRecognizer:singleTap]; singleTap.delegate = self; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } 

EDIT: It looks like the tab bar is hiding, but my webview just doesn't fill the empty space. How can I fill in the gap when the tab bar is hidden?

+4
source share
2 answers

First of all, your status bar is never displayed because you never talk about it. As written, your code simply tells the status bar to hide every time it executes.

 [[UIApplication sharedApplication] setStatusBarHidden:![[UIApplication sharedApplication] isStatusBarHidden] withAnimation:UIStatusBarAnimationSlide]; [self.navigationController setNavigationBarHidden:!self.navigationController.navigationBar.hidden animated:YES]; 

Also, I'm not sure in the details why your tab bar is not hiding properly, but I found the following category, which claims to be able to hide the tab bar with animating options.

https://github.com/idevsoftware/Cocoa-Touch-Additions/tree/master/UITabBarController_setHidden

+4
source

I got a status bar to hide / show by adding this to my toggleBars method, but I still don't understand why the elements of the tab bar are hidden, but not the tab bar itself.

 if (([UIApplication sharedApplication].statusBarHidden = YES)) { [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; } else { [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; } 
+1
source

Source: https://habr.com/ru/post/1496646/


All Articles