iphone app webview链接动作

Yaz*_*zmi 4 iphone objective-c uiwebview uiview

有没有办法让单击UIWebView的html中的链接来加载另一个UIView并将url的值传递给该视图,而不是在同一个UIWebView中加载该html页面.基本上,修改单击UIWebView中链接的默认操作.这可能吗?

dra*_*ard 6

在你的UIWebViewDelegate中执行以下操作:

- (BOOL)webView:(UIWebView *)webView
  shouldStartLoadWithRequest:(NSURLRequest *)request
  navigationType:(UIWebViewNavigationType)navigationType {

  if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
    // do something with [request URL]
    return NO;
  }
  return YES;
}
Run Code Online (Sandbox Code Playgroud)