[英]Lock and unlock orientation in phonegap
I want to enable and disable changes in orientation using phonegap. 我想使用phonegap启用和禁用方向更改。
For android there is the java call, 对于android,有java调用,
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
but I was looking for something that was cross-platform, there is also the config.xml 但我一直在寻找跨平台的东西,还有config.xml
<preference name="orientation" value="portrait"/>
but this is a global setting. 但这是一个全局设置。
Any suggestions? 有什么建议么?
for cross platform in android add this line for portrait mode 对于android中的跨平台,请将此行添加为纵向模式
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
and this one is for landscape 这是风景
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
just after this line 就在这条线之后
super.onCreate(savedInstanceState);
in your onCreate method,this solution is for android as i have not worked in ios i can not help you on it. 在您的onCreate方法中,此解决方案适用于android,因为我没有在ios中工作,我无法为您提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.