Use UIWebViewNavigationTypeLinkClicked Filter

ε祈祈猫儿з 提交于 2019-12-23 02:38:53

问题


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:


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


来源:https://stackoverflow.com/questions/19903783/use-uiwebviewnavigationtypelinkclicked-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!