Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

ios - IOS7 Status bar hide/show on select controllers

I would like to show and hide the Status bar on some controllers. Can this be done or is it more of an overall app setting.

I have seen many posts/questions about the plist update:

View controller-based status bar appearance - NO

If this is completed what control is then given?

I am looking to show the status bar on the main screen of the application. But for example on a side (slide) menu I would like it not to show, is this possible? Can this be changed in IB or code?

EDIT -- I am using a https://github.com/edgecase/ECSlidingViewController implementation.

The main controller (showing the first page) should show the Status bar, but the left menu controller when it slides should not.

I believe the issue is that they both sit within the same root controller (sliding view controller) so it is difficult to complete.

Ideally if the home screen (main page) could take the status bar with it when it slides that would look best.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The plist setting "View controller-based status bar appearance" only controls if a per-controller based setting should be applied on iOS 7.

If you set this plist option to NO, you have to manually enable and disable the status bar like (as it was until iOS 6):

[[UIApplication sharedApplication] setStatusBarHidden:YES]

If you set this plist option to YES, you can add this method to each of your viewControllers to set the statusBar independently for each controller (which is esp. nice if you have a smart subclass system of viewControllers)

- (BOOL)prefersStatusBarHidden {
    return YES;
}

Edit:

there are two more methods that are of interest if you are opting in the new viewController-based status bar appearance -

Force a statusbar update with:

[self setNeedsStatusBarAppearanceUpdate]

If you have nested controllers (e.g. a contentViewController in a TabBarController subclass, your TabBarController subclass might ask it's current childViewController and forward this setting. I think in your specific case that might be of use:

- (UIViewController *)childViewControllerForStatusBarHidden {
     return _myChildViewController;
}
- (UIViewController *)childViewControllerForStatusBarStyle {
     return _myOtherViewController;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...