我已经实现了带有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;
}