Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto hiding UINavigationBar and UIToolbar

I have an iPhone app that is based on a navigation controller.

I have a main view controller that displays a list of articles, and a detail view, where you can see one article in a UIWebView. For the detail view, I have the navigation bar on the top, and a UIToolbar on the bottom.

I'd like to auto-hide them with a slide animation (to top and bottom) and restore them when tapping the screen. I thought this would be a standard function, but couldn't find how to do it.

As a reference, this is what Stanza or the NYT app do.

like image 610
pgb Avatar asked Sep 08 '09 20:09

pgb


3 Answers

Set up a method that runs this on a tap event:

if (![navigationController isNavigationBarHidden])
  [navigationController setNavigationBarHidden:YES animated:YES]; // hides
else
  [navigationController setNavigationBarHidden:NO animated:YES]; // shows

As for the UIToolbar, it is a UIView subclass, so you should be able to pretty easily set up a custom animation for sliding this in and out of sight.

like image 102
Alex Reynolds Avatar answered Nov 05 '22 18:11

Alex Reynolds


There is also quite a useful method for UIVIewController.

- (BOOL) hidesBottomBarWhenPushed {
//hide a toolbar or whatever
return NO;
}
like image 35
knuku Avatar answered Nov 05 '22 17:11

knuku


Try this:

BOOL hide = ![self.navigationController isNavigationBarHidden];
[self.navigationController setNavigationBarHidden:hide animated:YES];
like image 1
Vingoradov.Ser Avatar answered Nov 05 '22 17:11

Vingoradov.Ser