我有一个根视图控制器来管理其中的所有其他控制器,所以我覆盖了所述rootViewController中的shouldAutorotate和supportedInterfaceOrientations,如下所示:
public override func shouldAutorotate() -> Bool {
if let vc = view.window?.rootViewController?.presentedViewController {
if NSStringFromClass(vc.classForCoder) == "AVFullScreenViewController" {
return true
}
}
return false
}
public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if let vc = view.window?.rootViewController?.presentedViewController {
if NSStringFromClass(vc.classForCoder) == "AVFullScreenViewController" {
return UIInterfaceOrientationMask.AllButUpsideDown
}
}
return UIInterfaceOrientationMask.Portrait
}
除了使用AVPlayerViewController查看全屏视频时,我的应用程序仅为纵向 .
上面的代码在整个应用程序中运行良好 . 我的所有控制器和他们的视图都保持纵向状态,当用户全屏播放视频时,它会旋转到横向而没有问题 .
我的问题是纵向模式下的状态栏没有粘贴到方向遮罩并旋转到横向,但状态栏然后隐藏在横向中 . 另一个奇怪的事情是,当应用程序处于横向状态时,控制中心和通知中心现在可以打开,就像应用程序处于横向状态一样 .
Min支持的iOS是9.0 . 有什么建议?
1 回答
我最终删除了我的根视图控制器中的上述代码,并将其添加到我的应用程序委托中 . 状态栏现在保持不变 .