开发者

UIWebView search [closed]

开发者 https://www.devze.com 2023-02-15 00:44 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. 开发者_Go百科 Want to improve this question? Update the question so it can be answered with facts and citatio
Closed. This question is opinion-based. It is not currently accepting answers.
开发者_Go百科

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 6 years ago.

Improve this question

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


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"];

0

精彩评论

暂无评论...
验证码 换一张
取 消