Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView search [closed]

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

like image 364
Dee Avatar asked Jan 21 '23 07:01

Dee


1 Answers

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

like image 96
Zakaria Avatar answered Jan 29 '23 05:01

Zakaria