IOS7 状态栏隐藏/显示在选择的控制器上 [英] IOS7 Status bar hide/show on select controllers

查看:17
本文介绍了IOS7 状态栏隐藏/显示在选择的控制器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些控制器上显示和隐藏状态栏.这是否可以完成,或者更像是一个整体的应用设置.

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.

我看过很多关于 plist 更新的帖子/问题:

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?

我希望在应用程序的主屏幕上显示状态栏.但是例如在侧面(幻灯片)菜单上我不希望它显示,这可能吗?这可以在 IB 或代码中更改吗?

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?

编辑——我正在使用 https://github.com/edgecase/ECSlidingViewController 实现.

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.

推荐答案

plist 设置 "View controller-based status bar appearance" 仅控制是否应在 iOS 上应用基于每个控制器的设置7.

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

如果将此 plist 选项设置为 NO,则必须手动启用和禁用状态栏,例如(直到 iOS 6):

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]

如果您将此 plist 选项设置为 YES,您可以将此方法添加到您的每个 viewController 中,以便为每个控制器独立设置 statusBar(尤其是如果您有一个智能的 viewController 子类系统,那就太好了)

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;
}

如果您选择新的基于 viewController 的状态栏外观,还有两种方法会很有趣 -

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

强制更新状态栏:

[self setNeedsStatusBarAppearanceUpdate]

如果您有嵌套的控制器(例如 TabBarController 子类中的 contentViewController,您的 TabBarController 子类可能会询问它是当前的 childViewController 并转发此设置.我认为在您的特定情况下可能有用:

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;
}

这篇关于IOS7 状态栏隐藏/显示在选择的控制器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆