【问题标题】:NativeScript modal take full screen on iosNativeScript 模态在 ios 上全屏显示
【发布时间】:2019-01-25 16:22:17
【问题描述】:

我尝试在我的 nativescript 项目中添加模式,它在 android 上按预期工作,但在 ios 上它占用了屏幕的全部高度和宽度,它应该部分显示。

我创建了一个单独的角度组件来打开它,我在下面的代码中使用。

它在 android 上运行良好,但在 ios 上它以全屏模式打开。

public showModal(fullscreen: boolean, animated = true, stretched = false) {
    const options: ModalDialogOptions = {
        context: { promptMsg: "This is the prompt message!" },
        fullscreen,
        animated,
        stretched,
        viewContainerRef: this.vcRef,
    };

    this.modal.showModal(ModalContent, options).then((res: string) => {
        this.result = res || "empty result";
    });

模态应该在 ios 上作为 android 部分打开。 有什么解决方法吗,请帮忙。

【问题讨论】:

    标签: android ios angular modal-dialog nativescript


    【解决方案1】:

    我认为 iPhone 不支持弹出式模式,只有 iPad 支持。一种解决方法是使用全屏模式,使背景透明并将您的内容放在中间。

    如果您熟悉原生 api,我想可以通过限制模态框的帧大小来完成。

    【讨论】:

    • 感谢您的回答,有一个可用的解决方法,我们可以将我们的模态作为子组件并传递一个事件来显示和隐藏,如果成功,我将发布代码。
    【解决方案2】:

    聚会有点晚了,但是我在 nativescript-angular 存储库中找到了一个 PR,它似乎使用 ModalDialogOptions 中的以下代码实现了 iOS 非全屏模式

     ios: {
            presentationStyle: UIModalPresentationStyle.Popover
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-06
      • 1970-01-01
      • 2011-12-19
      • 2018-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多