Can't hide status bar in AVPlayerViewController's portrait mode

不问归期 提交于 2019-12-08 06:15:06

问题


I'm developing an app that first presents a UICollectionView with a bunch of buttons that modally open a subclass of AVPlayerViewController with a custom "Over Full Screen" segue. UIViewControllerBasedStatusBarAppearance is set to YES in my Info.plist.

Here's a small (had to zoom out, sorry) screenshot of all the view controllers in Interface Builder:

The segue was defined in IB. When the user taps a collection view cell, I use performSegueWithIdentifier() to, well, perform the segue.

The problem I'm now experiencing is this:

Why does the status bar hide along with the playback controls in landscape mode, while doing the exact opposite in portrait mode?

Making prefersStatusBarHidden() return true in my subclass of AVPlayerViewController doesn't do anything. What gives?


回答1:


Just figured out a solution:

extension UINavigationController {
    public override func childViewControllerForStatusBarHidden() -> UIViewController? {
        return self.childViewControllers.last
    }

    public override func childViewControllerForStatusBarStyle() -> UIViewController? {
        return self.childViewControllers.last
    }
}

Yup, just override those two functions for all Navigation View Controllers in your app. I consider this to be a hack and not the 'correct' solution to this problem, so use this with caution.

As far as I can tell, this should never fail. In my app, every Navigation VC has exactly one child VC, but YMMV.



来源:https://stackoverflow.com/questions/33871020/cant-hide-status-bar-in-avplayerviewcontrollers-portrait-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!