问题描述
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:
- 在视图控制器上调用
SetNeedsStatusBarAppearanceUpdate()
(例如:显示a的视图控制器)全屏图片) - 在同一视图控制器上覆盖
PrefersStatusBarHidden()
。
- Invoke
SetNeedsStatusBarAppearanceUpdate ()
on the view controller (e.g.: a view controller that is showing a fullscreen image) - 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 - 隐藏子视图控制器上的状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!