我已經實現了帶有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;
}