我用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 *data = [NSMutableDictionary new]; [data setObject:request.URL.absoluteString ?:@"" forKey:@"url"]; [self fireEvent:@"pagestart" params:data]; } NSString * urlAbsoluteString= [request.URL absoluteString]; NSArray *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; }
self.schemesCallBacks裡存的value是WXCallback?建議換成WXKeepAliveCallback試試