我想检测设备方向更改事件。我需要改变图像,而在设备中改变方向。
我试过其中的一些例子,但根本行不通。我也尝试了screen-orientation插件,但它也不起作用。
我用的插件
ionic cordova plugin add cordova-plugin-screen-orientation
npm install @ionic-native/screen-orientation这些都在我的package.json里。
"@ionic-native/app-preferences": "^4.18.0",
"@ionic-native/call-number": "^4.18.0",
"@ionic-native/core": "~4.17.0",
"@ionic-native/file": "^5.0.0",
"ionic-angular": "3.9.2"发布于 2020-02-05 12:54:33
你试过用screen-orientation插件吗,你有:
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
constructor(private screenOrientation: ScreenOrientation) { }
...
this.screenOrientation.onChange().subscribe(
() => {
console.log("Orientation changed to " + this.screenOrientation.type);
}
); https://stackoverflow.com/questions/60072722
复制相似问题