Wrote about UIWebView not loading pictures, looked up a lot of information,
About JS, about OC, in StackOverflow and so did not find the right answer,
Finally feel that we should return to the traditional JS code,
Stringbyevaluatingjavascriptfromstring to invoke the JS method
JS Code:
var div_hide_css_id ="Ibrowser_div_hide_css";//-------------------have picture/no diagram----function Jshandlehideimage () {var i=0; var alldiv= document.getElementsByTagName ("DIV"); for(i; i<alldiv.length; i++) {var e=Alldiv[i]; var bg_image=E.style.backgroundimage; E.style.backgroundimage="None"; E.setattribute ("Bg_image", Bg_image); } var newcss=document.getElementById (div_hide_css_id); if(Newcss = =undefined) {Document.documentElement.innerHTML= document.documentelement.innerhtml+"<style id= '"+div_hide_css_id+"' >img{visibility:hidden;} </style>"; } Else { if(newcss.innerhtml = ="') {} newcss.innerhtml='Img{visibility:hidden;}'; }}function jshandleshowimage () {var i=0; var alldiv= document.getElementsByTagName ("DIV"); for(i; i<alldiv.length; i++) {var e=Alldiv[i]; var bg_image= E.getattribute ("Bg_image"); E.style.backgroundimage=Bg_image; } var newcss=document.getElementById (div_hide_css_id); if(newcss) {newcss.innerhtml='img{visibility:visibility;}'; }}
OC Code
if (// no picture) { [WebView stringbyevaluatingjavascriptfromstring:@ "jshandlehideimage ()"]; } Else { [webView stringbyevaluatingjavascriptfromstring:@ "jshandleshowimage () " ]; }
Images are not loaded in Ios:uiwebview (ie, the browser's common no-diagram mode)