Zoomscale detection in UIWebView

My problem is that I want to determine the zoom scale of the UIWebView, I tried to search for it, but did not get the correct answer. Any help is appreciated ......

+3
source share
1 answer

Good, but UIWebViewhas no property zoomScale, UIScrollViewdoes! Therefore, we just scan it subView'sfor scrollVieweverything sits and gets it that way.

Here is a small (1 method) category that will allow you to get scale by calling [webView zoomScale].

File UIWebView + zoom.h

@interface UIWebView (zoom)
-(float)zoomScale;
@end

File UIWebView + zoom.m

@implementation UIWebView (zoom)

-(float)zoomScale{
    UIScrollView *webViewContentView;
    for (UIView *checkView in [self subviews] ) {
        if ([checkView isKindOfClass:[UIScrollView class]]) {
            webViewContentView = (UIScrollView*)checkView;
            break;
        }
    }
    return webViewContentView.zoomScale;
}

@end

UIScrollView Class Reference

UIWebView ( , webView, Apple iOS)

. , , .

0

All Articles