You can simply click on the javascript touchend event (or touchesEnded in Obj-C) and check the status of window.getSelection() . There is also a javascript selectionchange event.
Another method I use is to check the selection state of a UIWebView by looping through subviews:
- (bool) selectionInWebView:(UIWebView*)webView { UIScrollView *scrollView = webView.scrollView; //assumes IO(6)? and scrollView is exposed. Loop subviews otherwise. UIView *browserView; for(int i = 0; scrollView.subviews.count; i++){ if([NSStringFromClass([scrollView.subviews[i] class]) isEqualToString:@"UIWebBrowserView"]){ browserView = scrollView.subviews[i]; break; } } if(browserView == nil) return false; for(int i = 0; browserView.subviews.count; i++){ if([NSStringFromClass([browserView.subviews[i] class]) isEqualToString:@"UIWebSelectionView"]){ //UIView *selectionView = browserView.subviews[i]; return true; //selection view exists, a selection is in progress } } return false; }
But your best option is to check the status of the choice when a fire is triggered or a touch event change event occurs.
source share