3

Is there a way to zoom out or reset a UiWebView programmatically ? if yes how ?

ehehhh
  • 1,066
  • 3
  • 16
  • 27
thndrkiss
  • 4,515
  • 8
  • 57
  • 96

3 Answers3

3

i think you should be able to manipulate the viewport using the safari meta tags

https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW6

For example, to set the viewport width to the width of the device, add this to your HTML file:

<meta name = "viewport" content = "width = device-width">

To set the initial scale to 1.0, add this to your HTML file:

<meta name = "viewport" content = "initial-scale = 1.0">

To set the initial scale and to turn off user scaling, add this to your HTML file:

<meta name = "viewport" content = "initial-scale = 2.3, user-scalable = no">
Cœur
  • 37,241
  • 25
  • 195
  • 267
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
  • 1
    Ya correct. But how to control it after the view is displayed and zoomed by the user ? – thndrkiss Aug 07 '10 at 17:22
  • The documentation states that by setting user-scalable to "no" will prevent the user from zooming at all? Maybe I am not understanding the question? – Aaron Saunders Aug 07 '10 at 17:35
0

It's not directly supported, but this thread has a workaround/solution.

Community
  • 1
  • 1
joelm
  • 8,741
  • 1
  • 19
  • 17
-1

If you want to reset the user scale to 1.0, at least on iOS 4.2 you can toggle scalesPageToFit:

webView.scalesPageToFit = NO;
webView.scalesPageToFit = YES;
Steve Madsen
  • 13,465
  • 4
  • 49
  • 67