1

I'm using a small UIWebView, and scalesPageToFit doesn't work correctly for some url. (look like it cannot resize at 100%. (but if i zoom out the webview manually(gesture), it work!

view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 400.0f)];
webViewT = [[UIWebView alloc] initWithFrame:view.bounds];
webViewT.delegate = self;
webViewT.scalesPageToFit = YES;
NSURL* url = [NSURL URLWithString:@"http://www.google.com/"];
[webViewT loadRequest:[NSURLRequest requestWithURL:url]];

Please note that i've found a solution:(below work, BUT I have the time to see a "resize"

- (void) webViewDidFinishLoad:(UIWebView *)webViewT {  
    if ([theWebView respondsToSelector:@selector(scrollView)])
    {
        UIScrollView *scroll=[theWebView scrollView];

        float zoom=theWebView.bounds.size.width/scroll.contentSize.width;
        [scroll setZoomScale:zoom animated:NO];
    }
}

Any idea? Thanks!

1

1 Answer 1

0

In Some of cases this types of problem Generated. At that time java script use for control of Zoom of UIWebView, use following code.

NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = 1.5;"];
[webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];

Other way is

Refer this Answer UIWebView does not scale content to fit

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.