0

嗨,我正在开发一个sencha-touch-2应用程序,它将嵌入在iPhone UIWebview上。UIWebview 大小为 280x420,以 iPhone 屏幕为中心。一切在 sencha 开发中都很完美,但是当我尝试将 sencha 构建到生产环境中时,sencha 页面的大小会拉伸或不适合 UIWebview 的大小。请看下面的代码

煎茶

将元标记添加到 index.html 的正文

<body>
    <meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1;">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <div id="appLoadingIndicator">
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>

此代码适用于开发,但当更改为生产时,页面会更改。我应该怎么做才能在生产版本中实现它,因为生产在加载时非常快。

4

1 回答 1

3

试试这个,只需将此脚本添加到您的 html 正文标记中。

<script type="text/javascript">
         setTimeout(function(){
             var meta = document.createElement('meta');
             meta.setAttribute("name","viewport");
             meta.setAttribute("content","width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;");
            (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(meta);
         },1000);
    </script>

Sencha touch 2.0 将使用内置的元标记覆盖您的脚本。因此,发生的情况是您的元标记将被加载,但将被它自己的元标记替换。

于 2012-07-01T12:15:39.813 回答