简体   繁体   中英

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

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.

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;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM