iphone 应用程序 webview 链接操作

标签 iphone objective-c uiview uiwebview

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

最佳答案

在你的UIWebViewDelegate这样做:

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

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

关于iphone 应用程序 webview 链接操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3218040/

相关文章:

iphone - 如何以编程方式滚动 UIScrollView?

ios - 在 UIView.animateWithDuration 之前完全取消隐藏 View

ios - 覆盖 AVCaptureVideoPreviewLayer

ios:onclick tableviewcell 如果 nsuserdefaults 存在转到 View Controller ,否则转到另一个 View Controller

iphone - UIScrollView和scrollRectToVisible :animated:

IOS8获取指纹数据

iOS 刷新辅助功能标签

ios - 如何通过从边缘拖动来调整 UIView 的大小?

iphone - 创建一个对象作为委托(delegate) - Objective C

ios - 在您的个人 iPhone 上开发应用程序 - 安全吗?