views:

1275

answers:

3

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.

+4  A: 

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.

Alex Reynolds
Do you know how can I detect the tap in my `UIWebView`?
pgb
A: 
BOOL hide = ![self.navigationController isNavigationBarHidden];
[self.navigationController setNavigationBarHidden:hide animated:YES];
Vingoradov.Ser
A: 

There is also quite a useful method for UIVIewController.

- (BOOL) hidesBottomBarWhenPushed {
//hide a toolbar or whatever
return NO;
}
NR4TR