当另一个 viewController 隐藏状态栏时 UINavigationBar 在状态栏下移动 [英] UINavigationBar moving under status bar when another viewController hides status bar

查看:32
本文介绍了当另一个 viewController 隐藏状态栏时 UINavigationBar 在状态栏下移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题很简单,Profile viewController 在状态栏下方有一个 NavigationBar.
我将另一个 viewController 推到当前的顶部.这个新的 viewController 隐藏了状态栏.

The problem is simple, the Profile viewController has a NavigationBar just under the status bar.
I push another viewController on top of the current one. This new viewController hides the status bar.

当我返回到 Profile viewController 时,navigationBar 已经向上移动了状态栏高度的大小.

When I go back to the Profile viewController, the navigationBar has moved up by the size of the status bar height.

我试图在我的 viewWillAppear 中强制刷新布局,但它不起作用.

I tried to force a layout refresh in my viewWillAppear but it doesn't work.

有什么想法吗?

推荐答案

在出现的视图控制器中实现 viewDidDisappear 并在进入 profileview 控制器之前再次显示状态栏.

Implement viewDidDisappear in that presented viewcontroller and show status bar again before come to profileview controller.

  override func viewWillDisappear(animated: Bool) {


    UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.Fade)
}

这篇关于当另一个 viewController 隐藏状态栏时 UINavigationBar 在状态栏下移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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