fill the void

Posted
8 November 2009 @ 2pm

Tagged
development

No Comments Yet

iPhone Tip: Conditional Toolbar

For an iPhone app I’m developing, I wanted a toolbar at the bottom of the initial view, but I didn’t want it appearing in the other views. I tried simply calling myUINavigationController.hidden, but the effect was a little jarring. UINavigationController has a great wrapper for that method that includes animation: setToolbarHidden:animated:. With animation, the toolbar smoothly slides in and out when going between the initial view and the other views. I inserted the method in UIViewController‘s viewWillAppear and viewWillDisappear.

// in a UIViewController subclass

- (void)viewWillAppear:(BOOL)animated {
	[self.navigationController setToolbarHidden:NO animated:YES];
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
	[self.navigationController setToolbarHidden:YES animated:YES];
	[super viewWillDisappear:animated];
}

No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment