Open skyylex opened 9 years ago
I have add an JS script in the webview did load method already resolved the issue. NSString zoomImage = [NSString stringWithFormat:@"var script = document.createElement('script');" "script.type = 'text/javascript';" "script.text = \"function ResizeImages() { " "var myimg,oldwidth;" "var maxwidth=%f;" "for(i=0;i <document.images.length;i++){" "myimg = document.images[i];" "if(myimg.width > maxwidth){" "oldwidth = myimg.width;" "myimg.width = maxwidth;" "myimg.height = myimg.height \ (maxwidth/oldwidth);" "}" "}" "}\";" "document.getElementsByTagName('head')[0].appendChild(script);",self.webView.frame.size.width-20]; [self.webView stringByEvaluatingJavaScriptFromString:zoomImage]; [self.webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
Thank you for solution's sharing. The alternative way for this is to insert an additional CSS file with image attributes. Did you check for performance and appearance issues? It's interesting to compare what will be work faster on huge amount of images (or for several huge images), and another question related to the appearing of such effect, is it smooth enough?
Add support of the zooming feature