tags:

views:

122

answers:

1

hi all, i want to hide and show navigation bar on double click. navigation bar consist of 2 bar buttons.

initially,navigation bar should be hidden. when user double taps the screen ,the navigation bar should come up with l'll animation,like we c in our iphone's photo gallery.

how can i do this,

suggestion are always appreciated

regards shishir

+1  A: 

This isn't something that can fit into a few lines of code, but this is one approach that might work for you.

To hide the navigation bar:

[[self navigationController] setNavigationBarHidden:YES animated:YES];

To show it:

[[self navigationController] setNavigationBarHidden:NO animated:YES];

Documentation for this method is available here.

To listen for a "double click" or double-tap, subclass UIView and make an instance of that subclass your view controller's view property.

In the view subclass, override its -touchesEnded:withEvent: method and count how many touches you get in a duration of time, by measuring the time between two consecutive taps, perhaps with -timeIntervalSinceDate:. Or test the result from [touch tapCount].

If you get two taps, your subclassed view issues an NSNotification that your view controller has registered to listen for.

When your view controller hears the notification, it fires a selector that either hides or shows the navigation bar using the aforementioned code, depending on the navigation bar's current visible state, accessed through reading the navigation bar's isHidden property.

Alex Reynolds
If this is for a photo viewer application, hiding the nav bar causes an unpleasant jump for the image view, which I haven't found how to prevent. 3.2 lets you use UIGestureRecognizer for double taps, which is a much neater approach (for iPad only atm).
Paul Lynch
Thanks a lot Alex,u provided me a lot of infoemation,i m gonna follow ur guidelines ..thanks a ton
shishir.bobby
is this same applied for tab bars???if i want to hide/show tab bars dan wat i hv to do?regardsshishir
shishir.bobby
http://stackoverflow.com/questions/815690/hide-uitabbar
Alex Reynolds
Is there any way to prevent this 'jump' Paul mentioned? I have the very same problem and I do not know, what causes it.... neither do I think, noone ever stumbled upon it.
Icky