我用weex本身提供的WXWebComponent
代码,从新写了一个自己的WebComponent
,并添加了拦截Url请求的方法,暴露给weex文件使用。
每次当我从myWebView
拦截Url
跳到一个weex
文件,再次pop
回来的时候,再次点击myWebView
的时候,就没办法将callback
事件返回给weex
文件。并出现以下错误提示
WeexDemo[23225:9905854] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
贴出我的webView拦截Url的部分代码
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if (_startLoadEvent) {
NSMutableDictionary<NSString *, id> *data = [NSMutableDictionary new];
[data setObject:request.URL.absoluteString ?:@"" forKey:@"url"];
[self fireEvent:@"pagestart" params:data];
}
NSString * urlAbsoluteString= [request.URL absoluteString];
NSArray <NSString *>*schemes = self.schemesCallBacks.allKeys;
for (NSString *scheme in schemes) {
NSError *error = nil;
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:scheme options:NSRegularExpressionCaseInsensitive error:&error];
if (!error) {
NSRange range = [regExp rangeOfFirstMatchInString:urlAbsoluteString options:NSMatchingReportProgress range:NSMakeRange(0, urlAbsoluteString.length)];
if (range.location != NSNotFound) {
WXCallback callBack = self.schemesCallBacks[scheme];
callBack(@{@"url": [request.URL absoluteString]});
return NO;
}
} else {
WXLog(@"created regExp error: %@", error);
}
}
return YES;
}