Click here to Skip to main content
13,862,130 members
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 19 Dec 2012
Licenced CPOL

How to Show Hide Navigation Bar When Tap in iOS Occurs

, 19 Dec 2012
Rate this:
Please Sign up or sign in to vote.
A quick tip that will show you how to show hide Navigation Bar when tap in iOS occurs

This is a quick tip that will show you how to show hide Navigation Bar when tap in iOS occurs. This is a great method if you want to benefit from every pixel of the screen real estate. So I suggest you do it when you have a view that will display images in fullscreen. An example is when you want to show hide Navigation Bar when the user taps the screen.

A lot of top apps use the show hide Navigation Bar, mainly when opening an image. Twitter, Facebook, eBay and a plethora of famous apps are using this technique. Why not you?

I will show you how in these simple steps in the following code.

Code for show/hide Navigation Bar

UITapGestureRecognizer *tapGesture = 
    [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showHideNavbar:)];
[self.view addGestureRecognizer:tapGesture];
-(void) showHideNavbar:(id) sender 
// write code to show/hide nav bar here 
// check if the Navigation Bar is shown
if (self.navigationController.navigationBar.hidden == NO)
   // hide the Navigation Bar
   [self.navigationController setNavigationBarHidden:YES animated:YES];
// if Navigation Bar is already hidden
else if (self.navigationController.navigationBar.hidden == YES)
   // Show the Navigation Bar
   [self.navigationController setNavigationBarHidden:NO animated:YES];

That’s all guys, now you got another tool that will make your app look cooler and more functional.

If you have any other idea of how to implement this thing, please leave a comment.

You can follow me on Twitter in my personal profile or Duuro App Studio profile.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Albania Albania
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190214.1 | Last Updated 19 Dec 2012
Article Copyright 2012 by Perjan
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid