Auto hiding UINavigationBar and UIToolbar

iphone, uinavigationcontroller

Solution

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.

Problem

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.

Original source