On the iPhone, how does one implement automatic hiding and navigation bar and toolbar like Image Browsing? In fact, it is very simple. You only need to set the display and hide attributes of the toolbar and navigationbar.
As follows:
Unhidden
Hidden
The specific implementation code is as follows:
First, set toolbarhidden = No in viewdidload. The default value is yes (hidden). To display the toolbar, set it to no (hidden ).
-(Void) viewdidload
{
[Super viewdidload];
Self. Title = @ "Hide navigation bar ";
// Self. toolbaritems
Self. navigationcontroller. toolbar. barstyle = self. toolbar. barstyle;
Self. navigationcontroller. toolbarhidden = no;
[Self. navigationcontroller. toolbar settranslucent: Yes];
Self. toolbaritems = [[nsmutablearray alloc] initwitharray: Self. toolbar. Items] autorelease];
}
Display and hide the navigation bar and toolbar when you click the intermediate button
The implementation code is as follows:
-(Ibaction) togglavigationbar :( ID) sender {
// Check the current state of the navigation bar...
Bool navbarstate = [self. navigationcontroller isnavigationbarhidden];
// Set the navigationbarhidden to the opposite of the current state.
[Self. navigationcontroller setnavigationbarhidden :! Navbarstate animated: Yes];
[Self. navigationcontroller settoolbarhidden :! Navbarstate animated: Yes];
// Change the label on the button.
If (navbarstate ){
[Button settitle: @ "Hide navigationr and toolbar" forstate: uicontrolstatenormal];
[Button settitle: @ "Hide navigation bar toolbar" forstate: uicontrolstatehighlighted];
} Else {
[Button settitle: @ "display navigation bar toolbar" forstate: uicontrolstatenormal];
[Button settitle: @ "display navigation bar toolbar" forstate: uicontrolstatehighlighted];
}
}
How can this effect be used? For example, when you click the area in the middle of a typical ebook, you can see some settings and navigation.
Link: http://www.cnblogs.com/likwo/archive/2011/06/12/2078760.htm
Indicate the source for reprinting.
Reference:
Http://www.raddonline.com/blogs/geek-journal/iphone-sdk-uinavigationcontroller-hiding-the-navigation-bar
Http://icodesnip.com/snippet/iphone/iphonesdkuinavigationbar