Appcelerator:iPhone上的Webview,具有iFrame和宽度 [英] Appcelerator: Webview on iPhone with an iFrame and width
问题描述
晚上好
我在内部具有Webview的视图遇到了一些问题. Web视图正在插入带有外部源(另一个域上的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.
主要问题是Web视图正在插入不需要的水平滚动条(因为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下,我将主体的最大宽度设置为320px,则可以正常使用.我不会这样做,因为我需要它在风景和iPad下工作.
- 如果我使用外部html作为Webview的URL,它也可以工作.因此,外部内容不是问题,而是本地html或webview和iframe.
有什么想法吗?
推荐答案
我结束了在外部文件上使用媒体查询,并且效果很好.
I ended using media queries on the external file and that works pretty well.
这篇关于Appcelerator:iPhone上的Webview,具有iFrame和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!