簡體   English   中英

如何使用點擊手勢(iOS8 / Swift)在pageViewController上顯示/隱藏狀態欄

[英]How can I show/hide the status bar on a pageViewController using tap gesture (iOS8 / Swift)

通過查看類似問題的所有解決方案,我一直在嘗試通過輕擊手勢顯示/隱藏statusBar

我在plist中設置了View controller-based status bar appearance = NO

我在我的DataViewController (頁面視圖控制器)和RootViewController嘗試了以下代碼:

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

它不起作用。

這是嵌入在UITabBarController ,會有所作為嗎?

此外,我能夠從RootViewController獲取以下內容來隱藏statusBar:

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

但是DataViewController甚至沒有調用這個函數,只能以這種方式永久隱藏它,而不是打開/關閉它。

有任何想法嗎?

我在代碼中嘗試過,一切都適合我。 確保View controller-based status bar appearance設置為NO 並且不需要覆蓋prefersStatusBarHidden()

如果您使用UIPageViewController那么您應該在RootViewController使用此代碼

如果你有一個navigationController它也會隱藏它

ViewDidLoad()

self.navigationController?.hidesBarsOnTap = true

並使用此方法根據是否隱藏navigationBar來隱藏或顯示狀態欄

override func prefersStatusBarHidden() -> Bool {
        if self.navigationController?.navigationBarHidden == true {
            return true
        }
        else
        {
            return false
        }
   }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM