Question

I know this question has been asked a couple of times before. I m trying to zoom in / out the uiwebview. How exactly do i do this? I tried setting 'webView.scalesPageToFit=YES;' but its not working.

I also tried this How do I enable the zoom in/out option in a 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. Can that be a problem??

If its the meta tag problem. 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..

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];
Was it helpful?

Solution

Zooming in and out and Pinch are built in feature of UIWebView. You don't need to write any code to achieve that.

OTHER TIPS

just simply set the property.

scalesPageToFit=YES

for any pinching and zooming to work on a UIWebView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top