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]; }
时间: 2024-10-17 17:04:38