【问题标题】:Can't hide status bar in AVPlayerViewController's portrait mode无法在 AVPlayerViewController 的竖屏模式下隐藏状态栏
【发布时间】:2016-02-25 13:23:30
【问题描述】:

我正在开发一个应用程序,它首先呈现一个带有一堆按钮的 UICollectionView,这些按钮以模态方式打开 AVPlayerViewController 的子类,并带有自定义的“Over Full Screen”segue。 UIViewControllerBasedStatusBarAppearance 在我的 Info.plist 中设置为 YES。

这是 Interface Builder 中所有视图控制器的小屏幕截图(不得不缩小,抱歉):

转场是在 IB 中定义的。当用户点击集合视图单元格时,我使用 performSegueWithIdentifier() 来执行转场。

我现在遇到的问题是:

为什么在横向模式下状态栏会随着播放控件一起隐藏,而在纵向模式下却完全相反?

在我的 AVPlayerViewController 子类中让 prefersStatusBarHidden() 返回 true 没有任何作用。什么给了?

【问题讨论】:

    标签: swift cocoa-touch ios9 avplayer avplayerviewcontroller


    【解决方案1】:

    刚刚想出了一个解决方案:

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

    是的,只需为您的应用中的 all 导航视图控制器覆盖这两个函数。我认为这是一种 hack,而不是解决此问题的“正确”解决方案,因此请谨慎使用。

    据我所知,这永远不会失败。在我的应用中,每个 Navigation VC 都只有一个子 VC,但 YMMV。

    【讨论】:

    • 我看到“方法不会覆盖其超类中的任何方法” - 您在 swift 3 中有更新的方法吗?
    猜你喜欢
    • 2017-03-01
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多