RunLoop RunLoop - 2 years ago 223
Objective-C Question

UIWebView does not scale content to fit

I have a webview which is the top window in the hierarchy and has been declared as shown below. However, it does not scale pages to fit. Pages are top left aligned, but are not scaled, despite the scalesPageToFit property being set to YES. Any help would be greatly appreciated.

webLookupView = [[UIWebView alloc] initWithFrame:CGRectMake(16, 63, 289, 327)];
webLookupView.backgroundColor = [UIColor lightGrayColor];
webLookupView.dataDetectorTypes = UIDataDetectorTypeAll;
webLookupView.scalesPageToFit = YES;

Answer Source

I have subsequently discovered that some web pages are correctly scaled, but some are not. For web pages which are not properly scaled, javascript can be used to control zooming as follows:

NSString *jsCommand = [NSString stringWithFormat:@" = 1.5;"];
[webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download