UIWebView search [closed]

允我心安 提交于 2019-12-04 08:22:20

问题


What is the best way to search for a string of text in a UIWebView?


回答1:


I think that the best to proceed is to:

  1. Create a javascript function that will find your text
  2. Use the stringByEvaluatingJavaScriptFromString: (see here) method to get the javascript code
  3. Call the same method to look for the javascript function (put this code in a function that will take the aString argument):

    NSString *findThisStringFnc = [NSString stringWithFormat:@"findThisString('%@')",aString];
    [self stringByEvaluatingJavaScriptFromString:findThisStringFnc ];

  4. Put all this code in a function (findAString for example) then call it from the UIWebView instance:
    [aWebView findAString:@"foobar"];



来源:https://stackoverflow.com/questions/5195390/uiwebview-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!