1
我需要從UIWebView中選擇一些文本。我提到這個答案Getting selected elements programatically from uiwebview?但是,當我使用點擊它選擇文本。但是,它會顯示所有的HTML人物造型也Selected Name: 1 Name of instrument
remove elementFromPoint()顯示HTML字符
-(void)singleTap:(UIGestureRecognizer *)gestureRecognizer
{
NSLog(@"single tap");
CGPoint touchPoint = [gestureRecognizer locationInView:wbCont];
//NSString *js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).toString()", touchPoint.x, touchPoint.y];
NSString *js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).innerHTML", touchPoint.x, touchPoint.y];
NSString * tagName = [wbCont stringByEvaluatingJavaScriptFromString:js];
NSLog(@"Selected Name: %@",tagName);
}