【问题标题】:modalPresentationStyle default value in iOS 13iOS 13 中的 modalPresentationStyle 默认值
【发布时间】:2019-09-30 09:30:24
【问题描述】:

根据苹果文档,

此属性的默认值为 UIModalPresentationStyle.automatic

在 iOS 12 中,默认值为 UIModalPresentationStyle.fullScreen,这就是我得到的。

但是当我在 iOS 13 上运行我的应用程序时,我收到了.pageSheet as navigationController.modalPresentationStyle

我做错了什么还是默认值为 .pageSheet?

【问题讨论】:

    标签: ios swift uiviewcontroller uimodalpresentationstyle


    【解决方案1】:
    1. UIModalPresentationStyle.automatic 在 .pageSheet 和 .fullScreen 之间切换,具体取决于 UIViewController 所呈现的上下文。李>
    2. 如果您使用普通 UIViewController,它将默认为 .pageSheet。
    3. 但是,如果您使用 UIViewController 的某些子类,例如 UIImagePickerController,iOS 期望内容应处于全屏模式,因此默认为 .fullscreen .
    4. 如果您使用 iOS 版本低于 13,它将始终默认为 .fullscreen。

    【讨论】:

      【解决方案2】:

      系统选择的默认演示样式。它是 UIModalPresentationAutomatic

      自动意味着如果我们使用UIImagePickerController 和sourceType .photoLibrary,那么它会以级联视图的形式出现。而 sourceType .camera 则全屏显示。

      https://developer.apple.com/videos/play/wwdc2019/224/

      https://developer.apple.com/documentation/uikit/uimodalpresentationstyle/uimodalpresentationpagesheet?language=objc

      【讨论】:

        【解决方案3】:

        在 iOS 13 中,当您以模态方式呈现视图控制器时,呈现样式为自动,默认为页面表

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-05-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多