0

アップルは多くの広告を無効にしたフラッシュを禁止しましたが. 私はまだ、ブラウザの広告ブロックのような機能が好きです。

すべての読み込みリクエストの URL をチェックすることで、adblock がそうしていることに気付きました。UIWebviewでそれは可能ですか?

どんな提案でも結構です ありがとう

4

1 に答える 1

1

いいえ。

ただし、リクエストが最初から発行されないようにスウィズルすることができます。 -[NSURLRequest initWithURL:cachePolicy:timeoutInterval:]

static id (*oldMethod)(id self, SEL _cmd, NSURL* theURL, ....);

static id newMethod(id self, SEL _cmd, NSURL* theURL, ....) {
    if ([[theURL absoluteString] hasPrefix:@"http://example.com"]) {
        [self release];
        return nil;
    }
    return oldMethod(self, _cmd, theURL, cachePolicy, timeoutInterval);
}

....


Method m = class_getInstanceMethod([NSURLRequest class], 
                                  @selector(initWithURL:cachePolicy:timeoutInterval:));
oldMethod = method_setImplementation(m, newMethod);

一般に、返却nilは安全ではないことに注意してください。リクエストが何らかのデータ構造に保存され、プログラムがクラッシュする可能性があります。

于 2010-08-10T09:42:09.460 に答える