3
votes

every one:

I can enable zooming by setting scalesPageToFit to YES. But, how can I know whether UIWebView is zooming?

Does anyone know that?

Thanks in advance.

2
Just a shot in the dark but could you do something with the Pinch Gesture Recogniser in relation to the UIWebView? - Harry Lawrence

2 Answers

3
votes

Resolved.

add a new property to XXXViewController to store current zoom scale (compared to initial scale)

@property (nonatomic, assign) float zoomScale;

set initial value of zoomScale at some proper place (e.g. viewDidLoad?)

self.zoomScale = 1.0f;

update zoom scale when the scale of ScrollView is changed (the ScrollView of UIWebView)

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{
    self.zoomScale *= scale;
}

if zoomScale is within certain range (almost 1.0), the WebView is not zooming

if(self.zoomScale - 1.0 < 0.001 && self.zoomScale - 1.0 > - 0.001) {
    // Not zooming
}

And, if you want to change the scale, you should

- (void)changeWebViewScale:(float)scale
{
    [self.webView.scrollView setZoomScale:scale / self.zoomScale animated:YES];
}
0
votes

http://www.seeques.com/19639347/how-to-detect-zoom-scale-of-uiwebview.html

In my case I had to add a scrolview var and scrolviewdelegate,then set that scrolview to webview's scrolview to be able to call scrolviewdidendzooming method