【问题标题】:phonegap 2.2 orientation change does not resize appphonegap 2.2 方向更改不会调整应用程序大小
【发布时间】:2012-11-20 21:05:28
【问题描述】:

我在以前版本的 Phonegap 上没有这个问题。但在 2.2 中,当我更改方向时,它不会更新 uiwebview

phonegap 默认不支持横屏吗?你是怎么处理的?

【问题讨论】:

    标签: ios cordova


    【解决方案1】:

    这不是 WebView 更新的问题,而是 index.html 文档头中的元标记。

    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    

    删除不必要的height=device-height 后一切正常

    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />
    

    【讨论】:

    • 非常感谢,height=device-height 在 Android 上工作(没有受到伤害),在为 iOs 删除它之后,我用 android 重新测试并发现它首先是不必要的,所以一个很好的解决方案
    • 是的,但是如果您删除 height=device-height ,您会遇到键盘覆盖屏幕的问题。
    【解决方案2】:

    补充斯蒂芬的回答,如果你需要在方向改变时做任何特别的事情,你可以设置一个回调函数:

    window.onorientationchange

    【讨论】:

      【解决方案3】:

      我在 ios phonegap 中也有同样的问题 ....

      只需去更新 x-code 项目文件(IOS 应用程序目标)更改或更新支持界面方向并检查所有方向。

      效果很好……

      【讨论】:

      • 是的,就是这样。在 Xcode Targets-> Your App -> iPhone/iPad Deployment Info -> "Supported Interface Orientations" 中。单击您希望支持的每个方向。默认情况下,似乎只启用了肖像。
      • 在代码方面,这些选项位于platforms/ios/appname/appname-Info.plist&lt;key&gt;UISupportedInterfaceOrientations&lt;/key&gt; &lt;array&gt; &lt;string&gt;UIInterfaceConstant&lt;/string&gt; &lt;/array&gt; 将字符串UIInterfaceConstant 替换为these constants 中的任何一个(因此每个支持的方向一个字符串元素)。对于 iPad 来说也是一样,但关键是 &lt;key&gt;UISupportedInterfaceOrientations~ipad&lt;/key&gt;
      【解决方案4】:
      window.addEventListener(
          "orientationchange",
          function() {
              // Announce the new orientation number
              location.reload();
          }, false );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多