How can I search in an UIWebView?

2020-02-26 13:53发布

I need to perform search in an html page displayed in a UIWebView control. The functionality I need is something that Safari has, when you hit command/ctrl F for searching the document for some word and the program highlights the hits for you. Is there any easy solution for this problem?

2条回答
乱世女痞
2楼-- · 2020-02-26 14:28

I know it's been a long time since you asked this question, but it's still a pretty common question people have so I put together a sample project in case anyone else is asking the same question. The project is a super simple app that loads an HTML file and can search and highlight any keyword. You can download the sample project here:

https://www.dropbox.com/s/jietctrvrtnec28/TheSearcher.zip?dl=0

Scott

Edit: changed link above as the old one had broken.

查看更多
登录 后发表回答