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

查看:118
本文介绍了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 实现。

主控制器(显示第一页)应显示状态栏,但是当它滑动时左边的菜单控制器不应该。

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设置查看基于控制器的状态栏外观仅控制是否基于每个控制器的设置应该在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,则可以将此方法添加到每个viewControllers中,以便为每个控制器独立设置statusBar(特别是。如果你有一个智能的viewControllers子类系统,那就太好了)

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 -

强制状态栏更新with:

Force a statusbar update with:

[self setNeedsStatusBarAppearanceUpdate]

如果您有嵌套控制器(例如一个contentViewController在TabBarController子类,你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天全站免登陆