Detect long press on UIWebview and pop up a menu if I'm pressing on a link

有些话、适合烂在心里 提交于 2020-01-12 09:55:46

问题


Running into a problem with UIWebview, it doesn't seem to react to gesture recognizer. I would like to get a popover to appear whenever I do a long press on a link (or image) with different actions.

Any help would be greatly appreciated =). Thanks.


回答1:


You can detect clicking on a URL like this

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

   if (navigationType == UIWebViewNavigationTypeLinkClicked) {  
   NSURL *URL = [request URL];  
   if ([[URL scheme] isEqualToString:@"http://"]) {    
      //It is a URL

   }else{  
       //Not a URL  
   }  
   return YES;

}


来源:https://stackoverflow.com/questions/4009760/detect-long-press-on-uiwebview-and-pop-up-a-menu-if-im-pressing-on-a-link

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