20
votes

I have a WebView into which I'm loading a local HTML page with some embedded images. I want to allow the user to zoom in on the text and image in a similar fashion as they would with the web browser.

Any ideas how to enable this?

Thanks

4

4 Answers

54
votes

Try to set UIWebView property scalesPageToFit to YES

5
votes

For completeness. You must enable multitouch, scalesPagesToFit to get it to work (there are some conditions if its within certain other views).

But then to prevent it scaling your webpage (especially if using local files). You will need to add the following snippet to your HTML

For more info so: http://iphoneincubator.com/blog/windows-views/right-scale-for-a-uiwebview

5
votes

This is the code that works for me:

// declare and allocate UIWebView before
// UIWebView *webView;
// webView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, w, h)];
webView.scalesPageToFit = YES;

4
votes

I used scalesPageToFit to YES.... it allows it to zoom in some... but not a true zoom like safari has.