- (void)webViewDidFinishLoad:(UIWebView *)webView{
webViewDidLoad = YES;
hideManualHud(0);
[webView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function ResizeImages() { "
"var myimg,oldwidth;"
"var maxwidth=%lf;" //縮放系數(shù)
"for(i=0;i <document.images.length;i++){"
"myimg = document.images[i];"
"if(myimg.width > maxwidth){"
"oldwidth = myimg.width;"
"oldHeight = myimg.height;"
"myimg.width = maxwidth;"
"myimg.height = oldHeight * (maxwidth/oldwidth);"
"}"
"}"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);",Screen_Width - 10 ]];
//攔截網(wǎng)頁圖片 并修改圖片大小
[webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
}
這個(gè)會(huì)有個(gè)小問題伐坏,在實(shí)際使用中禀综,網(wǎng)絡(luò)環(huán)境較差就會(huì)有一個(gè)從大壓到小的過程掠廓,如果有誰有好的解決方法换怖,可以發(fā)評(píng)論給我,謝謝大神