iOS 7 - 隐藏子视图控制器上的状态栏 [英] iOS 7 - Hide status bar on a child view controller

查看:331
本文介绍了iOS 7 - 隐藏子视图控制器上的状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIApplication.SharedApplication.SetStatusBarHidden (MonoTouch代码,但也适用于Obj-C)为iOS 6做了工作,但对于iOS 7,我们必须:

UIApplication.SharedApplication.SetStatusBarHidden(MonoTouch code, but also applies to Obj-C) does the job for iOS 6, but for iOS 7 we must:


  1. 在视图控制器上调用 SetNeedsStatusBarAppearanceUpdate()(例如:显示a的视图控制器)全屏图片)

  2. 在同一视图控制器上覆盖 PrefersStatusBarHidden()

  1. Invoke SetNeedsStatusBarAppearanceUpdate () on the view controller (e.g.: a view controller that is showing a fullscreen image)
  2. Override PrefersStatusBarHidden () on the same view controller.

然而,上面提到的视图控制器嵌入在导航栏中,导航栏也嵌入在滑出菜单中。即使使用 AddChildViewController()将所有嵌入式视图控制器添加到层次结构中,尝试更新子视图控制器中的状态栏也无效。

However the view controller mentioned above is embedded in a navigation bar, which is also embedded in a slideout menu. Even though all embedded view controllers are added to the hierarchy using AddChildViewController(), attempting to update the status bar in a child view controller has no effect.

任何想法?

编辑

Window.RootViewController (Menu)
|___ ViewControllerA (Navigation Bar)
     |___ ViewControllerB (Actual View controller)

其中 ViewControllerB 想要隐藏/显示状态bar

Where ViewControllerB wants to hide/show the status bar

推荐答案

ViewControllerA应覆盖childViewControllerForStatusBarHidden并返回ViewControllerB。

ViewControllerA should override childViewControllerForStatusBarHidden and return ViewControllerB.

- (UIViewController *)childViewControllerForStatusBarHidden {
    return _viewControllerB;
}

这篇关于iOS 7 - 隐藏子视图控制器上的状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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