简体   繁体   中英

Block images in UIWebView by domain name

I would like to stop a UIWebView from loading specific images. The problem is that, although the images change, the domain name stays the same; for example, adsmarket.com .

<a target="_blank" href="http://network.adsmarket.com/click/imVtnmGcqZWQaWmcX8p8mItoasReyoCYj2JylV_Kf5qMYnLEYaB6lomQbJdknnqV">
    <img width="728" height="90" border="0" src="http://network.adsmarket.com/stc/35021/6471901/ctv.png">
</a>

I want this blocked IN the UIWebView , and no, I can't edit the page's HTML.

You should try looking at this answer. Rob's suggestion (and a subsequent answer that expands on it) won't be trivial to implement, but is doable.

Or, check out this other answer to another question . In this one, yonel suggests implementing your own NSURLCache . When one of the images from adsmarket.com is requested, you would return an image from your cache (which could be a dummy image ... maybe clear or 1x1 pixel), instead of letting the request go to the real adsmarket.com server. The cached image would just be something local, bundled in your app, not a remote image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM