【问题标题】:iOS: 13 - remove space between status bar and scrollview [duplicate]iOS:13-删除状态栏和滚动视图之间的空间[重复]
【发布时间】:2020-05-25 17:11:24
【问题描述】:

最近,我将我的 Xcode 从 10.1 更新到 11.3,我注意到一些功能发生了变化,当我在 iOS 13 的模拟器上运行我的应用程序时,我看到状态栏和我用于主页的滚动视图,请参阅附图:

https://i.stack.imgur.com/uoFE7.png

https://i.stack.imgur.com/Rb0FV.png

如何解决?

【问题讨论】:

  • 对不起,我的错。我是新来的。谢谢!

标签: ios swift ios13 xcode11.3


【解决方案1】:

如果您可以推送视图控制器,请考虑 Roberto 的回答。如果使用现在:

故事板解决方案:

如果您仍想使用 present,则在 storyboard 中将 segue 演示更改为 Full Screen

以编程方式:

let vc = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "yourVC") as! YourVC
    vc.modalPresentationStyle = .fullScreen // add this
    self.present(vc, animated: true, completion: nil)

【讨论】:

    【解决方案2】:

    虽然 Roberto 的回答并非完全错误,但您仍然可以使用 present(...) 并通过设置呈现的控制器的过渡来实现所需的 UI:

    let vc = // initiate
    vc.modalPresentationStyle = .fullScreen
    present(vc, animation: true, completion: nil)
    

    您正在体验的是 iOS 13 中的新默认行为,这非常好(您可以拉下新控制器以将其关闭)。

    当然,这会导致以这种方式呈现新控制器的旧应用程序的行为有所不同。

    【讨论】:

      【解决方案3】:

      这是因为您使用了代码来呈现视图控制器。

      present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) 方法将以模态方式显示您的视图控制器。 https://developer.apple.com/documentation/uikit/uiviewcontroller

      如果你不想要那种效果,你必须使用pushViewController(_ viewController: UIViewController, animated: Bool) https://developer.apple.com/documentation/uikit/uinavigationcontroller

      【讨论】:

      • 将行为从 present 更改为 push 不是一个合适的解决方案,仅仅为了编辑演示转换而更改整个行为是没有意义的。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      • 2017-01-15
      • 1970-01-01
      • 2020-10-16
      • 2014-08-29
      • 2016-11-09
      相关资源
      最近更新 更多