cordova - Ionic 2 - 仅为 iPad 启用横向

标签 cordova angular typescript ionic2

我可以在 config.xml 中将方向设置为仅纵向,如下所示:

<preference name="Orientation" value="portrait"/>

但是我怎样才能允许 iPad 构建横向,同时仍然像上面那样对 iPhone 禁用?

最佳答案

据 Ionic 的 Mike Harrison 说,他说:

Other than manually rotating the device, not really. This would be something you'd writing a plugin for to modify the main App view in cordova

但是有一个 Plugin from Ionic 1 .看它。最终您也可以在 Ionic 2 中使用它。

有了这个插件,你可以做这样的事情:

if(/(ipad)/i.test(navigator.userAgent)) {
  //THIS IS THE PLUGIN IONIC 1 CODE 
  $scope.changeOriantationPortrait = function() {
            screen.lockOrientation('portrait');
        }   
}

关于cordova - Ionic 2 - 仅为 iPad 启用横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43179396/

相关文章:

javascript - ' Uncaught Error : Can't resolve all parameters for' runtime error when upgrading from Angular 4 to 5. 0.1

javascript - 我的 addZipcode 函数未在 Angular 2 应用程序的模板 View 中显示新值

reactjs - 找不到模块 'react-redux' 的声明文件。

javascript - Angular 6 - 如何读取特定于 Angular 属性

javascript - 多图像上传到 Cordova 中的服务器

javascript - Javascript 中 "replace"的不同行为

node.js - 谷歌风格的分页

javascript - typescript 计算数组中的重复项并按每个项目的计数对结果进行排序

android - Flurry + PhoneGap 3.1.0 使用 github.com/jfpsf/flurry-phonegap-plugin

ios - Cordova 3.1.0 : Plugin not found or is not a CDVPlugin