Ionic framework 离子2:android中的纵向和横向屏幕方向
当我在纵向和横向两个方向上旋转屏幕,但安卓应用程序爱奥尼亚2没有旋转 config.xmlIonic framework 离子2:android中的纵向和横向屏幕方向,ionic-framework,ionic2,Ionic Framework,Ionic2,当我在纵向和横向两个方向上旋转屏幕,但安卓应用程序爱奥尼亚2没有旋转 config.xml <preference name='orientation' value='portrait'/> 我找到了这个问题的答案,当手机屏幕方向改变时,应用程序也会随着手机方向旋转 首先,从confix.xml中删除方向首选项 然后在app.component.js中编写此代码 import { ScreenOrientation } from '@ionic-native/screen-orie
<preference name='orientation' value='portrait'/>
我找到了这个问题的答案,当手机屏幕方向改变时,应用程序也会随着手机方向旋转 首先,从confix.xml中删除方向首选项 然后在app.component.js中编写此代码
import { ScreenOrientation } from '@ionic-native/screen-orientation';
initializeApp() {
this.platform.ready().then(() => {
if (this.platform.isPortrait) { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); } else { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT); }
this.statusBar.styleDefault();
this.initPushNotification();
});
}
if (this.platform.is('android')) {
this.ScreenOrientation.onChange().subscribe(() => {
if (this.platform.isPortrait) {
this.ScreenOrientation.unlock()
}
else {
this.ScreenOrientation.lock(this.ScreenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY)
}
});
}
app.component.js
import { ScreenOrientation } from '@ionic-native/screen-orientation';
initializeApp() {
this.platform.ready().then(() => {
if (this.platform.isPortrait) { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); } else { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT); }
this.statusBar.styleDefault();
this.initPushNotification();
});
}
if (this.platform.is('android')) {
this.ScreenOrientation.onChange().subscribe(() => {
if (this.platform.isPortrait) {
this.ScreenOrientation.unlock()
}
else {
this.ScreenOrientation.lock(this.ScreenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY)
}
});
}
我找到了这个问题的答案,当手机屏幕方向改变时,应用程序也会随着手机方向旋转 首先,从confix.xml中删除方向首选项 然后在app.component.js中编写此代码
import { ScreenOrientation } from '@ionic-native/screen-orientation';
initializeApp() {
this.platform.ready().then(() => {
if (this.platform.isPortrait) { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); } else { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT); }
this.statusBar.styleDefault();
this.initPushNotification();
});
}
if (this.platform.is('android')) {
this.ScreenOrientation.onChange().subscribe(() => {
if (this.platform.isPortrait) {
this.ScreenOrientation.unlock()
}
else {
this.ScreenOrientation.lock(this.ScreenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY)
}
});
}
app.component.js
import { ScreenOrientation } from '@ionic-native/screen-orientation';
initializeApp() {
this.platform.ready().then(() => {
if (this.platform.isPortrait) { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); } else { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT); }
this.statusBar.styleDefault();
this.initPushNotification();
});
}
if (this.platform.is('android')) {
this.ScreenOrientation.onChange().subscribe(() => {
if (this.platform.isPortrait) {
this.ScreenOrientation.unlock()
}
else {
this.ScreenOrientation.lock(this.ScreenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY)
}
});
}
首先安装
爱奥尼亚cordova插件添加cordova插件屏幕方向
npm安装--保存@ionic native/屏幕方向
app.component.ts
import { ScreenOrientation } from '@ionic-native/screen-orientation';
constructor(private screenOrientation: ScreenOrientation) { }
// set to landscape
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
// allow user rotate
this.screenOrientation.unlock();
or
constructor(private screenOrientation: ScreenOrientation) {
this.screenOrientation.lock('portrait');
}
首先安装
爱奥尼亚cordova插件添加cordova插件屏幕方向
npm安装--保存@ionic native/屏幕方向
app.component.ts
import { ScreenOrientation } from '@ionic-native/screen-orientation';
constructor(private screenOrientation: ScreenOrientation) { }
// set to landscape
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
// allow user rotate
this.screenOrientation.unlock();
or
constructor(private screenOrientation: ScreenOrientation) {
this.screenOrientation.lock('portrait');
}
你的问题是什么?我想用手机的屏幕方向旋转应用程序你的问题是什么?我想用手机的屏幕方向旋转应用程序单页是否可行?单页是否可行?