使用 UIWebViewNavigationTypeLinkClicked 过滤器 [英] Use UIWebViewNavigationTypeLinkClicked Filter

查看:34
本文介绍了使用 UIWebViewNavigationTypeLinkClicked 过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 UIWebViewNavigationTypeLinkClicked 存储点击的 URL.但是,在点击一些带有广告的网址后,我只想存储点击的网址而不是一系列网址.无论如何要处理这个?

I want to store the clicked URL by UIWebViewNavigationTypeLinkClicked. However I just want to store the clicked URL not a series of URLs after clicking in some URLs with ads. Anyway to deal with this?

推荐答案

当你点击 webview 下面的委托时,你需要实现下面的委托方法,然后在此基础上你可以检查那个 url 并相应地存储在一个数组中-

When you clicked inside webview below delegate will called you need to implement below delegate method then on the basis of this you can check that url and store in an array accordingly-

  - (BOOL)webView:(UIWebView *)webView 
shouldStartLoadWithRequest:(NSURLRequest 
 *)request navigationType:
  (UIWebViewNavigationType)navigationType
{
//here you can check the condition on the basis
 of navigation type
  if   (navigationType==
  UIWebViewNavigationTypeLinkClicked)
{  //Store the link in array below
// initialized you array somewhere first and then
  use below
[mutableArray addObject:yourUrl];
    }
}

这篇关于使用 UIWebViewNavigationTypeLinkClicked 过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆