ios - Creating a new web component using WXWebComponent code, the following problem occurs
phpcn_u1582
phpcn_u1582 2017-05-31 10:32:17
0
1
702

I used the WXWebComponent code provided by weex itself, rewrote my own WebComponent, and added a method to intercept Url requests, exposing it to weex files.

Problem Description

Every time when I intercept Url from myWebView jump to a weex file and pop back again, click againmyWebView, there is no way to return the callback event to the weex file. And the following error message appears

WeexDemo[23225:9905854] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

Post part of the code for my webView to intercept 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;
}
phpcn_u1582
phpcn_u1582

reply all(1)
Peter_Zhu

The value stored in self.schemesCallBacks is WXCallback? It is recommended to try WXKeepAliveCallback instead

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!