Appcelerator:带有 iFrame 和宽度的 iPhone 上的 Webview [英] Appcelerator: Webview on iPhone with an iFrame and width

查看:14
本文介绍了Appcelerator:带有 iFrame 和宽度的 iPhone 上的 Webview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,

我在处理内部有 webview 的视图时遇到了一些问题.webview 正在插入一个带有外部源(另一个域上的 html)的 iframe.我正在使用 iframe,因为我需要使用外部 HTML 并且我需要与我的应用程序进行点击/触摸事件通信.

I've been having some issues with a view that has a webview inside. The webview is inserting an iframe with an external source (an html on another domain). I'm using an iframe since I need to use the external HTML and I need to communicate with click/touch events with my application.

主要问题是 webview 插入了不需要的水平滚动条(因为 iframe 内容太大)

The main issue is that the webview is inserting unwanted horizontal scroll bars (because the iframe content is too big)

代码如下:

网络视图:

var webview = Titanium.UI.createWebView({
    url: "/html/local.html",
    width:Ti.UI.SIZE,
    height:Ti.UI.SIZE,
    contentWidth:Ti.UI.SIZE,
    contentHeight:Ti.UI.SIZE,
    disableBounce:true,
    enableZoomControls: false
});
self.add(webview);

iframe:

<html>
    <head>
        <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
        <meta http-equiv="cleartype" content="on">
        <script>
            function init () {
                window.theIframe.TiAPI = Ti.API;
                window.theIframe.TiApp = Ti.App;
            }
        </script>               
        <style>
            body {width:100%;margin:0;padding:0;background-color:#ccffff;}
        </style>
    </head>
    <body>
        <iframe name="theIframe" src="http://external.com/something.html" width="100%" height="100%" frameborder="0" onload="init()">
        </iframe>
    </body>
</html>

注意事项:

  • 这只发生在肖像上.它在 iPad 或 iPhone 的横向视图上运行良好.
  • 如果在外部 html 下,我将主体的最大宽度设置为 320 像素,它就可以完美运行.我不会这样做,因为我需要它在横向和 iPad 下工作.
  • 如果我使用外部 html 作为 web 视图的 URL,它也可以工作.所以这不是外部内容的问题,而是本地 html 或 webview 和 iframe 的问题.

有什么想法吗?

推荐答案

我结束在外部文件上使用媒体查询,效果很好.

I ended using media queries on the external file and that works pretty well.

这篇关于Appcelerator:带有 iFrame 和宽度的 iPhone 上的 Webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆