【发布时间】: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
});
使两者之间的旋转跳跃看起来很糟糕。
【问题讨论】:
-
我与 Ionic 合作得还不够多,无法知道您是否有 angular CDK 或 Material,但如果有,您可以使用他们的 BreakpointObserver material.angular.io/cdk/layout/overview
标签: android ios angular ionic-framework