-1

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

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

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

怎么修?

4

3 回答 3

2

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

故事板解决方案:

如果您仍想使用 present,则将 segue Presentation 更改为Full Screenin the storyboard 。

在此处输入图像描述

以编程方式:

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)
于 2020-02-10T11:56:53.720 回答
1

那是因为您用于呈现视图控制器的代码。

该方法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

于 2020-02-10T11:33:40.140 回答
0

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

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

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

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

于 2020-02-10T11:52:58.080 回答