【问题标题】:Detect device rotation/orientation in Ionic 4 without rotating app在不旋转应用程序的情况下检测 Ionic 4 中的设备旋转/方向
【发布时间】:2020-03-24 22:17:44
【问题描述】:

是否可以在不实际旋转整个应用程序的情况下检测 Ionic 4 应用程序中的旋转/方向变化?

我正在使用这个: https://ionicframework.com/docs/native/screen-orientation

我想输入一些关于设备旋转的回调,而不一定要旋转整个应用程序。如果我锁定方向,我会丢失 screenOrientation.onChange() 发出的信息。如果我解锁旋转,我的 screenOrientation.onChange() 会发出,但整个应用程序的 webview 也会旋转。

尝试这样的事情:

this.screenOrientation.unlock();
this.screenOrientation.onChange().subscribe(ev => {
        this.screenOrientation.lock(
          this.screenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY
        );
        // Do other stuff
});

使两者之间的旋转跳跃看起来很糟糕。

【问题讨论】:

标签: android ios angular ionic-framework


【解决方案1】:

你可以试试这个

您应该将此行添加到项目中的 config.xml 中。

<preference name="orientation" value="portrait" />

【讨论】:

    猜你喜欢
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多