Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone UIWebView - How do you set the zoom level and position?

I'm displaying a series of tiled images in a UIWebView and would like to programmatically set the UIWebview's initial zoom and view location.

How does one go about doing so?

like image 569
Mike Avatar asked Mar 23 '09 17:03

Mike


2 Answers

Set attribute scalesPageToFit of UIWebView to YES. Then the webpage is scaled to fit and the user can zoom in and zoom out.

like image 182
Richard Chen Avatar answered Nov 12 '22 06:11

Richard Chen


You can use this:

for (UIView *subview in webView.subviews) {
    if ([subview isKindOfClass:[UIScrollView class]]) {
        ((UIScrollView *)subview).bounces = NO;
        [((UIScrollView *)subview) setZoomScale:10.5f animated:YES];
    }
}

It may be the solution to your problem.

like image 21
Arunjack Avatar answered Nov 12 '22 05:11

Arunjack