Today using WebView loading HTML, found that the picture is too large, no adaptation screen, so I set webview.scalespagetofit = YES, after the setting, the picture is really small, but the text is correspondingly reduced, and the picture is too small, nothing to match the screen, does not meet my requirements , so I thought of using JS to solve
1- (void) Webviewdidfinishload: (UIWebView *) Web2 {3 intCount = [[WebView stringbyevaluatingjavascriptfromstring:@"Document.images.length"] Intvalue];//get the number of IMG tags4 for(intI=0; i<count; i++) {5[WebView stringbyevaluatingjavascriptfromstring:[nsstring stringWithFormat:@"document.images[%d].style.maxwidth= ' 100%% '", I]];//picture width 100% fit, if greater than 320, zoom, if less than not processed6[WebView stringbyevaluatingjavascriptfromstring:[nsstring stringWithFormat:@"document.images[%d].style.height= ' auto '", I]];//Picture Height Adaptive7 }8}
WebView picture Adaptation screen when loading HTML