Mobile 如何使用Ionic框架强制特定视图成为横向视图
我有一个应用程序在Mobile 如何使用Ionic框架强制特定视图成为横向视图,mobile,ionic-framework,orientation,Mobile,Ionic Framework,Orientation,我有一个应用程序在config.xml中强制显示纵向,但我希望应用程序中的特定视图显示为横向。实现这一目标的最佳方式是什么?系统中是否已有选项 我曾尝试通过CSS将视图控制器设置为将页面容器元素旋转90度,但这是一个错误的做法,因为操作系统不知道设备应该旋转,因此状态栏/OS导航项不会旋转 在使用该插件时,是否有办法将特定视图强制到指定的方向?似乎该插件将帮助您 对于横向,必须使用screen.lockOrientation(“横向”) 在其他页面上,如果它们不在纵向视图中,则必须放置scree
config.xml
中强制显示纵向,但我希望应用程序中的特定视图显示为横向。实现这一目标的最佳方式是什么?系统中是否已有选项
我曾尝试通过CSS将视图控制器设置为将页面容器元素旋转90度,但这是一个错误的做法,因为操作系统不知道设备应该旋转,因此状态栏/OS导航项不会旋转
在使用该插件时,是否有办法将特定视图强制到指定的方向?似乎该插件将帮助您
对于横向,必须使用screen.lockOrientation(“横向”)控制器中的代码>
在其他页面上,如果它们不在纵向视图中,则必须放置screen.lockOrientation(“纵向”)代码>对于Ionic 2.x,可以使用Ionic原生插件
import { ScreenOrientation } from '@ionic-native/screen-orientation';
constructor(private screenOrientation: ScreenOrientation) { }
...
// get current
console.log(this.screenOrientation.type); // logs the current orientation, example: 'landscape'
// set to landscape
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
// allow user rotate
this.screenOrientation.unlock();
// detect orientation changes
this.screenOrientation.onChange().subscribe(
() => {
console.log("Orientation Changed");
}
);
请参阅。好问题。然而,据我所知,这是不可能在离子框架,但如果有人知道解决方案,请纠正我。