2017-07-31 67 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函數將調用
相關問題