How to enable auto-hide and navigation bar and toolbar like Image Browsing in iPhone

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.