简体   繁体   中英

uiwebview zoom text

I want to make a button that zooms the content of a html page like in the desktop version of safari. I think I might have to use javascript for this? if thats the case, how can I zoom a page with javascript? in UIWebView

UIWebView embeds a UIScrollView, you can subclass UIWebView and add this method :

- (void)findScrollView {
    // Browse all subviews of view
    for (UIView *view in self.subviews) {
        // If current subview is a UIScrollView
        if ([view isKindOfClass:[UIScrollView class]]) {
            // Get UIScrollView object
            m_scrollView = (UIScrollView *) view;

            // Exit
            return;
        }
    }
}

to find the scroll view.

Once the UIScrollView found, you can easily zoom in/out and scroll via the UIScrollView methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM