【问题标题】:remove elementFromPoint() displaying HTML charactor删除显示 HTML 字符的 elementFromPoint()
【发布时间】:2013-10-15 06:52:33
【问题描述】:

我需要从 UIWebView 中选择一些文本。我提到了这个答案Getting selected elements programatically from uiwebview? 但是当我使用点击它选择文本时。但它也显示所有 HTML 字符 Selected Name: 1       Name of instrument

-(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);

 }

【问题讨论】:

    标签: javascript iphone uiwebview


    【解决方案1】:

    我从stringByReplacingOccurrencesOfString: 函数中得到了答案。我使用下面的代码。它工作正常。

    tagName=[tagName stringByReplacingOccurrencesOfString:@" " withString:@""];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-16
      • 2022-07-21
      相关资源
      最近更新 更多