我使用 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;}