如何使用点击手势(iOS8 / Swift)在pageViewController上显示/隐藏状态栏 [英] How can I show/hide the status bar on a pageViewController using tap gesture (iOS8 / Swift)

查看:276
本文介绍了如何使用点击手势(iOS8 / Swift)在pageViewController上显示/隐藏状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过查看类似问题的所有解决方案,我一直试图通过点击手势显示/隐藏 statusBar

Looking through all the solutions given to similar questions, I have been trying to get the statusBar to show/hide with a tap gesture.

我设置在plist中查看基于控制器的状态栏外观= NO

我在我的 DataViewController (页面视图控制器)和 RootViewController 中尝试了以下代码:

I have tried the following code in my DataViewController (page view controller) AND in the RootViewController:

let app = UIApplication.sharedApplication()
app.setStatusBarHidden(true, withAnimation: UIStatusBarAnimation.Fade)

它不起作用。

这是嵌入的一个 UITabBarController ,会有所作为吗?

This is embedded in a UITabBarController, would that make a difference?

另外,我能够从 RootViewController 中隐藏statusBar:

Also, I was able to get the following to hide the statusBar from the RootViewController:

override func prefersStatusBarHidden() -> Bool {
    return true
}

但是 DataViewController 甚至没有调用此函数,只能以这种方式永久隐藏它,而不是打开/关闭它。

But the DataViewController does not even call this function, and was only able to hide it permanently this way, rather than toggle it on/off.

任何想法?

推荐答案

我在代码中尝试过,一切都适合我。确保基于控制器的视图状态栏外观设置为。并且无需覆盖 prefersStatusBarHidden()

I have tried it in code, everything works fine for me. Make sure that the View controller-based status bar appearance is Set to NO. And there is no needs to override prefersStatusBarHidden().

这篇关于如何使用点击手势(iOS8 / Swift)在pageViewController上显示/隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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