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!

iPatel
  • 46,010
  • 16
  • 115
  • 137
Franck
  • 8,939
  • 8
  • 39
  • 57
  • possible duplicate of [UIWebView does not scale content to fit](http://stackoverflow.com/questions/1511707/uiwebview-does-not-scale-content-to-fit) – Max MacLeod Oct 10 '14 at 11:44

1 Answers1

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

Community
  • 1
  • 1
iPatel
  • 46,010
  • 16
  • 115
  • 137