iPhone 上 UIWebView 的 URL 过滤
有人可以解释一下我如何让它工作吗: http://www .icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/
我尝试在项目中制作“FilteredWebCache.h”和“FilteredWebCache.m”文件,但它说“FilterManager.h”不存在。我打算如何处理这些文件?
我将其放入 viewDidLoad 中:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
NSString *path = docDir; // the path to the cache file
NSUInteger discCapacity = 10*1024*1024;
NSUInteger memoryCapacity = 512*1024;
FilteredWebCache *cache = [[FilteredWebCache alloc] initWithMemoryCapacity:memoryCapacity diskCapacity:discCapacity diskPath:path];
[NSURLCache setSharedURLCache:cache];
[cache release];
Can someone please shed some light on how I would get this to work:
http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/
I tried making the "FilteredWebCache.h" and "FilteredWebCache.m" files in my project, but it said that "FilterManager.h" did not exist. What am I meant to do with those files?
This I put in viewDidLoad:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
NSString *path = docDir; // the path to the cache file
NSUInteger discCapacity = 10*1024*1024;
NSUInteger memoryCapacity = 512*1024;
FilteredWebCache *cache = [[FilteredWebCache alloc] initWithMemoryCapacity:memoryCapacity diskCapacity:discCapacity diskPath:path];
[NSURLCache setSharedURLCache:cache];
[cache release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要自己编写FilterManager类(FilterManager.m和FilterManager.h)。那篇文章说:
示例代码似乎将其称为 FilterMgr 而不是 FilterManager,并且看起来您需要提供一个 shouldBlockURL: 方法来决定阻止什么内容。
You need to write the FilterManager class yourself (FilterManager.m and FilterManager.h). That post says:
The example code seems to call it FilterMgr instead of FilterManager, and it looks like you need to provide a shouldBlockURL: method that decides what gets blocked.