我需要设置android设备智能手机肖像只? window.isTablet只能找到手机或平板电脑,所以我需要设置屏幕锁定方向并编写代码。如何在Phonegap中查找Android平板电脑或移动设备?
1
A
回答
2
使用
我们Cordova Screen Orientation Plugin固定。
在下面的代码app.js
document.addEventListener("deviceready", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});
window.addEventListener("orientationchange", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});
0
如果你想允许potrait
模式只,再加入 -
<platform name="android">
<preference name="Orientation" value="portrait" />
<allow-intent href="market:*" />
</platform>
内<widget>
标签在3210在项目文件夹。
就此Cordova Device插件而言,您可能未找到Tablet or Mobile version
插件。
可以得到以下properties -
- device.cordova //版本科尔多瓦的设备上运行。
- device.model //设备的模型或产品
- device.platform //设备的操作系统名称
- device.uuid
- device.version
- device.manufacturer //设备的制造商的名称。
- device.isVirtual //设备是虚拟的(模拟)或真实
- device.serial
0
使用,
document.addEventListener("deviceready", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});
相关问题
- 1. 如何在PHP中检测移动设备和平板电脑
- 2. 如何检测平板电脑或移动设备编程的设备类型
- 3. 检测Ipad,平板电脑或移动设备使用jQuery
- 4. Android布局设计:平板电脑第一或移动第一
- 5. Android平板电脑设备无法连接电脑
- 6. 移动和平板电脑设备标题截止Wordpress
- 7. 平板电脑/移动设备上的backbone.js和调试
- 8. Bootstrap Navbar不能在移动设备或平板电脑上崩溃
- 9. 如何在移动设备/平板电脑上使用EXTJS应用程序?
- 10. 如何在平板电脑/移动设备上对这些列进行分类?
- 11. 如何检测缺少GPS的Android平板电脑设备?
- 12. 如何检测当前设备是Android平板电脑?
- 13. 如何与Android平板电脑的USB设备进行通信?
- 14. Android平板电脑?
- 15. 将Appmaker应用程序部署到移动设备或平板电脑上?
- 16. 是当前设备平板电脑吗?
- 17. 媒体查询不适用于大型移动设备(平板电脑)
- 18. 如何禁用移动设备和平板电脑视图上的视差?
- 19. 在USB设备浏览文件在Android平板电脑
- 20. 如何确定设备是Android平板电脑还是Android电视
- 21. 如何在移动设备和平板电脑设备中制作好看的自定义用户界面?
- 22. LocalNotifications问题在Android平板电脑和iPad设备
- 23. Android的布局设计为平板电脑和设备
- 24. 从平板电脑移动到手机
- 25. 测试平板电脑移动webapp
- 26. asp.net网站,移动/平板电脑
- 27. Sumologic和Android平板电脑
- 28. Android平板电脑Listview
- 29. 使用Android平板电脑访问其他设备
- 30. Android应用程序适用于移动设备,但不适用于平板电脑设备
由于您使用的温泉UI,看看'ons.ready'和'ons.orientation'公用事业处理这很容易。 –
感谢@FranDios的建议.. – Santhoshkumar