简体   繁体   English

如何在uiwebview上添加捏和缩放-iPhone

[英]how to add pinch and zoom on a uiwebview - iphone

I know this question has been asked a couple of times before. 我知道这个问题已经问过几次了。 I m trying to zoom in / out the uiwebview. 我正在尝试放大/缩小uiwebview。 How exactly do i do this? 我到底该怎么做? I tried setting 'webView.scalesPageToFit=YES;' 我尝试设置'webView.scalesPageToFit = YES;' but its not working. 但它不起作用。

I also tried this How do I enable the zoom in/out option in a UIWebView? 我也尝试过如何在UIWebView中启用放大/缩小选项? but yet im not able to achieve the zoom in / out 但我无法实现放大/缩小

Code

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[actorUrlArray objectAtIndex:_rowNumberInActivity]]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
webView.scalesPageToFit=YES;

what am i missing out here? 我在这里错过了什么?

NOTE : I'm loading the iphone app on the ipad to check the app. 注意 :我正在将iphone应用程序加载到ipad上以检查该应用程序。 Can that be a problem?? 这会是一个问题吗?

If its the meta tag problem. 如果是meta标签问题。 how do i set them? 我该如何设置它们? i tried this code.. but its not working.. i know nothing about javascript.. so im not sure whether this is correct or not.. 我试过此代码..但无法正常工作..我对javascript一无所知..所以我不确定这是否正确..

NSString* js = 
@"var meta = document.createElement('meta'); \" \"meta.setAttribute( 'name', 'viewport' ); \" \"meta.setAttribute( 'content', 'width = device-width, initial-scale = 5.0, user-scalable = yes' ); \" \"document.getElementsByTagName('head')[0].appendChild(meta)";

[webView stringByEvaluatingJavaScriptFromString: js];

Zooming in and out and Pinch are built in feature of UIWebView. UIWebView内置了放大和缩小以及Pinch。 You don't need to write any code to achieve that. 您无需编写任何代码即可实现这一目标。

just simply set the property. 只需设置属性即可。

scalesPageToFit=YES scalesPageToFit =是

for any pinching and zooming to work on a UIWebView 任何缩小和缩放以在UIWebView上工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM