使用UIWebViewNavigationTypeLinkClicked过滤器

时间:2013-11-11 10:14:37

标签: ios objective-c uiwebview

我想通过UIWebViewNavigationTypeLinkClicked存储点击的网址。但是,我只想在点击带广告的某些网址后,将点击的网址存储为一系列网址。无论如何要对付这个?

1 个答案:

答案 0 :(得分:0)

当您在webview中单击时,委托将调用您需要实现下面的委托方法,然后在此基础上您可以检查该URL并相应地存储在数组中 -

  - (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];
    }
}