【问题标题】:Segue causes UITabBarController to shift status bar up in Swift?Segue 导致 UITabBarController 在 Swift 中向上移动状态栏?
【发布时间】:2016-03-21 01:36:56
【问题描述】:

关于如何限制屏幕方向,我遇到了一个奇怪的问题。

这是我的故事板的样子:

我将屏幕方向设置为仅纵向

在我的 AppDelegate 中,我有以下内容:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
    if self.window?.rootViewController?.presentedViewController is VideoPlayerViewController
    {
        return UIInterfaceOrientationMask.Landscape;
    }
    else
    {
        return UIInterfaceOrientationMask.Portrait;
    }
}

在“主页”选项卡中,单击红色播放按钮或任何单元格都会转到我的 VideoPlayerViewController。我已将 VideoPlayerViewController 限制为仅限横向。

然而,就在转场发生之前,这发生了:

基本上,发生的事情是在第二张图片中,红色部分向上移动,将状态栏推开。

然后在第三张图片中,前 2 个选项卡略微向 left 移动,而最后 2 个选项卡向 向右 略微移动。

再一次,所有这些都发生在 Modal segue 发生之前。

这可能是什么原因造成的?如果我需要包含其他代码,请告诉我。

【问题讨论】:

  • 您能告诉我们您在故事板中设置的约束吗?
  • 有很多限制。我可以在 github 上发布一个示例代码,以便您查看并帮助调试问题?

标签: ios swift uitabbarcontroller uiinterfaceorientation


【解决方案1】:

为了尽可能多地删除不相关的代码,以便在 github 上发布示例代码供其他人帮助调试,我找到了问题的罪魁祸首。

在我的代码中与override func prefersStatusBarHidden()有关,导致状态栏移位,现已解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    • 2018-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多