Use UIWebViewNavigationTypeLinkClicked Filter

2019-05-31 08:42发布

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?

1条回答
我只想做你的唯一
2楼-- · 2019-05-31 09:35

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];
    }
}
查看更多
登录 后发表回答