ios - 用WXWebComponent代码创建一个新的web组件,出现以下问题
phpcn_u1582
phpcn_u1582 2017-05-31 10:32:17
0
1
662

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

全部回复 (1)
Peter_Zhu

self.schemesCallBacks里存的value是WXCallback?建议换成WXKeepAliveCallback试试

    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责声明 Sitemap
    PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!