私はGCDを使用してUIWebViewでjavascriptを実行します。通常のjavasciptの場合、すべてが検出されたように見えますが、「アラート」に関しては、ポップアップモーダルビューによってユーザーインターフェイスが応答しなくなります。
これがUIWebViewDelegateメソッドの私のコードです。
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSLog(@"RECEIVED");
BOOL re =[WebParserStrategy shouldConsiderAsRequest:request];
NSLog(@"--receive Request: %@ jumpTo:%@", request.URL.absoluteString, re == YES ? @"YES" : @"NO!!");
if(re == NO)
{
dispatch_async(parserRequestToMessageQueue, ^{
NSString *msg;
NSDictionary *param;
[WebParserStrategy transferRequest:request toMessage:&msg withParam:¶m];
WebObserverChain *chain = [self.messageObservers objectForKey:msg];
if(chain == nil)
;//NSLog(@"!!!unknow message:%@ not found in message list", msg);
else {
dispatch_async(dispatch_get_main_queue(), ^{
[self.webView stringByEvaluatingJavaScriptFromString:@"alert('')"];
});
}
});
}
return re;}