iOS 以编程方式捏合
我为 iPhone 开发了一个基于 PhoneGap 的应用程序,效果非常好。该应用程序使用名为 ChildBrowser 的 iPhone PhoneGap 插件。该插件工作得很好,但它缺少 2 个功能,我想在 Objective-C 中自己编写代码来满足我的需求。
- 必须有一些函数可以在 WebView 加载的页面上执行 JavaScript。我已经做到了并且正在发挥作用。
- 需要一个函数,它接受 2 个参数(x 和 y 坐标)并在 webview 加载完成后立即放大网页。
我可以创建 te 函数和所有 JS 内容,但我不确定如何以编程方式实际执行放大/缩小。我读到了有关 ScrollView 的内容,但我不明白如何才能使其与 WebView 一起使用。 WebView 中是否有任何可以放大网页的方法属性(我看没有)?
I have developed an PhoneGap based app for IPhone which works very good. The app uses IPhone PhoneGap plugin called ChildBrowser. The plugin works superb but it lacked 2 features which I wanted to code myself in objective-c to fulfill my need.
- There has to be some function which can execute JavaScript on WebView loaded page. I have done it and it's working.
- There is a need of a function that take 2 parameters (x and y co-ordinates) and zoom in the webpage inside webview as soon as it's finished loading.
I can create te function and all JS stuff but I am not sure how to actually perform zoom-in/pinch-out programmatically. I read about ScrollView but I am not getting it how can I get it to work with WebView. Is there any property to method in WebView (I see no) which can zoom-in the webpage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,UIWebView 默认情况下是可缩放的。
您可以尝试检查 html 文件中是否有这一行:
这将阻止缩放。
关于你的第一个问题,你可以通过 (看这里):
如果你想在 UIWebView 加载完成时触发某些行为,那么你可以使用 UIWebView 的委托:
Actually,
UIWebView
s are zoomable by default.You can try and check whether you have this line in your html file:
this will prevent zooming.
As to your first question, you can execute JS through (look here):
and if you want to trigger some behavior when the UIWebView finished loading, then you can use the UIWebView's delegate:
我相信应该根据您在 html 页面标题的视口元标记中放置的内容来启用或不启用 webview 的缩放功能。
将阻止 webview 允许缩放,您可以了解更多信息 此处
I believe the zoom feature of the webview should be enabled or not according what you put in the viewport meta tag of the html page header.
<meta name="viewport" content="width=320, user-scalable=no">
will prevent the webview to allow zooming, you can learn more about it here