首页 > 移动平台 > 详细

ios开发 uiwebview加载网页时阻止禁止取消图片下载

时间:2015-07-12 17:16:50      阅读:216      评论:0      收藏:0      [点我收藏+]

http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/

 

- (NSCachedURLResponse*)cachedResponseForRequest:(NSURLRequest*)request
{
   NSURL *url = [request URL];
   BOOL blockURL = [url.absoluteString hasSuffix:@"jpg"] || [url.absoluteString hasSuffix:@"jpeg"] || [url.absoluteString hasSuffix:@"png"] || [url.absoluteString hasSuffix:@"gif"] || [url.absoluteString hasSuffix:@"ico"] || [url.absoluteString hasSuffix:@"JPG"] || [url.absoluteString hasSuffix:@"JPEG"];
   if (blockURL) {
     NSURLResponse *response =
         [[NSURLResponse alloc] initWithURL:url
                                MIMEType:@"text/plain"
                       expectedContentLength:1
                            textEncodingName:nil];
    NSCachedURLResponse *cachedResponse =
          [[NSCachedURLResponse alloc] initWithResponse:response
                         data:[NSData dataWithBytes:" " length:1]];

    [super storeCachedResponse:cachedResponse forRequest:request];

    [cachedResponse release];
    [response release];
}
    return [super cachedResponseForRequest:request];
}

 

ios开发 uiwebview加载网页时阻止禁止取消图片下载

原文:http://www.cnblogs.com/jackson-leung/p/4641157.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!