Search code examples
iphoneiosuiwebviewzooming

UIWebView's zoom range is very limited


I have a test UIWebView. I loaded a small amount of custom HTML into it. Nothing special -- two pages, a little text, and a small image on one of the pages. I am using it to test out the class.

One problem I am having is that my ability to zoom in and out is very limited. It seems that even if I set the minimumZoomScale and maximumZoomScale properties of the UIWebView's UIScrollView, something resets them to a factor of 1.5 or smaller ratio. And if I try to set them often, the app gets very unhappy and is prone to crash.

Can anyone explain what is going on?


Solution

  • You need to put the following line in the head section of your HTML document.

    <meta name="viewport" content="user-scalable=yes,maximum-scale=5.0,minimum-scale=0.25" />
    

    Docs regarding this: http://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariHTMLRef/Articles/MetaTags.html