IOS9, the sub-controller in the navigation controller sets the issue of StatusBar state failure

Source: Internet
Author: User

Two ways to control StatusBar before IOS9:

The first way: Global control StatusBar

1. Set Uiviewcontrollerbasedstatusbarappearance to No in the project's Info.plist file.

2. Use [[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent]; method to set the color.

The second way: Controller-based control of the STATUSBAR1. Set Uiviewcontrollerbasedstatusbarappearance to Yes in the project's Info.plist file. 2. Control the color and status of the status bar in each uiviewcontroller. By implementing the following methods in the controller to set the status bar color status-(Uistatusbarstyle) Preferredstatusbarstyle

-(BOOL) Prefersstatusbarhidden

There are currently only two colors available: uistatusbarstylelightcontent-white character uistatusbarstyledefault-black word

-------------------------

The problem with the second approach is that if a controller is inside the Uinavigationcontroller, then the above method of controlling statusbar is not called.

Workaround: Let Uinavigationcontroller implement-(Uiviewcontroller *) Childviewcontrollerforstatusbarstyle method. Return the top-level controller. That's all you can do.

You can write a uinavigationcontroller category to implement this method. Included in the project.

-(Uiviewcontroller *) Childviewcontrollerforstatusbarstyle

{

return self.topviewcontroller;

}

Another: Model out of the controller, and Uinavigationcontroller itself is not affected!

IOS9, the sub-controller in the navigation controller sets the issue of StatusBar state failure

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.