iPhone 上 UIWebView 的 URL 过滤

发布于 2024-08-28 01:21:07 字数 874 浏览 6 评论 0原文

有人可以解释一下我如何让它工作吗: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2024-09-04 01:21:07

您需要自己编写FilterManager类(FilterManager.m和FilterManager.h)。那篇文章说:

代码首先检查 URL 是否应该被阻止(FilterManager 类正在执行所有这些检查,此类未在此处显示)。

示例代码似乎将其称为 FilterMgr 而不是 FilterManager,并且看起来您需要提供一个 shouldBlockURL: 方法来决定阻止什么内容。

BOOL blockURL = [[FilterMgr sharedFilterMgr] shouldBlockURL:url];

You need to write the FilterManager class yourself (FilterManager.m and FilterManager.h). That post says:

The code first checks if the URL should be blocked (the FilterManager class is doing all these checks, this class isn’t shown here).

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.

BOOL blockURL = [[FilterMgr sharedFilterMgr] shouldBlockURL:url];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文