Detect long press on UIWebview and pop up a menu i

2019-03-31 02:00发布

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条回答
仙女界的扛把子
2楼-- · 2019-03-31 02:59

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;

}
查看更多
登录 后发表回答