UIWebView search [closed]
开发者_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 questionWhat is the best way to search for a string of text in a UIWebView
?
I think that the best to proceed is to:
- Create a javascript function that will find your text
- Use the
stringByEvaluatingJavaScriptFromString:
(see here) method to get the javascript code Call the same method to look for the
javascript
function (put this code in a function that will take theaString
argument):NSString *findThisStringFnc = [NSString stringWithFormat:@"findThisString('%@')",aString];
[self stringByEvaluatingJavaScriptFromString:findThisStringFnc ];Put all this code in a function (
findAString
for example) then call it from theUIWebView
instance:
[aWebView findAString:@"foobar"];
精彩评论