iPhone 中 HTML 文档的搜索功能
我正在开发一个 iPhone 应用程序,其中我创建了 HTML 页面。我有一个“网页”类,其中我只有一个 UIWebView。在运行时,我正在创建此类的对象并加载 HTML 内容,以便用户可以滚动页面。对于内存处理,我一次仅加载三页。现在我想向应用程序添加搜索功能。即,如果用户在应用程序中搜索单词或短语,应用程序应显示以下列表包含该单词的页面。我可以访问页面的名称来自数据库,但我不知道如何搜索所有 HTML 页面,因为一次只有一些页面加载到 webviews 中。我可以搜索应用程序中的 HTML 页面吗?如果是,那么如何?请帮助我,因为我有HTML 方面的经验很少。
I am working on an iPhone application in which I have HTML pages created with me.I have a class 'Webpage' in which I just have a UIWebView.At runtime I am creating objects of this class and loading it with HTML content so user can scroll through pages.For memory handling,I am loading only three pages at a time.Now I want to add a search facility to the application.i.e.If the user searches for a word or phrase in the application,the application should show a list of pages containing that word.I can access the names of pages from database but I don't know how can I search through all HTML pages as at a time only some pages are loaded in webviews.Can I search through the HTML pages in my application?If yes then how?Please help me as I have little experience with HTML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能听起来有点奇怪,但这是所有可用解决方案中最有效的一个。
我使用数据库来存储所有 HTML 页面的内容和标题,并使用“Like”查询在数据库中搜索单词。此外,我还使用了 Naveen Tunga 提到的突出显示方法。谢谢 Naveen ;)
这两种方法(即数据库和突出显示)的组合完成了这项工作。
This may sound bit odd but that's what was the most efficient one out of all the available solutions.
I used database to store the contents and title of all the HTML pages and used 'Like' query to search for a word into the database.Also I used highlighting method as mentioned by Naveen Thunga.Thanks Naveen ;)
Combination of these two methods i.e.database and highlighting did the job.