【发布时间】:2017-07-31 14:51:58
【问题描述】:
我已经用 HTML 内容实现了UIWebView。
UIWebView *webView=[[UIWebView alloc] initWithFrame:subView.frame];
webView.delegate=self;
webView.backgroundColor=[UIColor clearColor];
[webView addSubview:chartWebView];
[webView loadHTMLString:htmlContentString baseURL: [[NSBundle mainBundle] bundleURL]];
当 webview 加载委托方法时,它工作正常,但是当我点击一个链接时,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;
}
【问题讨论】:
标签: ios objective-c uiwebview uiwebviewdelegate