2017-07-31 36 views
0

我已经实现了带有HTML内容的UIWebView当我点击UIWebView时,shouldStartLoadWithRequest不起作用

UIWebView *webView=[[UIWebView alloc] initWithFrame:subView.frame]; 
webView.delegate=self; 
webView.backgroundColor=[UIColor clearColor]; 
[webView addSubview:chartWebView]; 
[webView loadHTMLString:htmlContentString baseURL: [[NSBundle mainBundle] bundleURL]]; 

当web视图加载委托方法,它的正常工作,但是当我点击一个链接,该shouldStartLoadWithRequest方法不叫。

我写的方法如下图所示:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{ 
    if ([[[request URL] absoluteString] hasPrefix:@"ios:"]) 
    { 
     [self performSelector:@selector(getValuesFromWebToNative)]; 

     return NO; 
    } 
    return YES; 
} 

回答

-1

web视图有一个子视图chartWebView。如果链接位于chartWebView中,则可能不会调用委托方法。我无法从您的代码中获得足够的细节。你可以发布更多细节。

1

集代表两个webViewchartWebView然后尝试,当链接按下

shouldStartLoadWithRequest函数将调用
相关问题