iPhone的自动填充搜索示例 [英] Autocomplete search example for iPhone

查看:98
本文介绍了iPhone的自动填充搜索示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能指出我如何在iPhone上实现自动完成搜索界面。我假设我需要使用NSTimer来定期检查已输入的内容,然后将该部分字符串提交到我的数据源,然后显示它们。

Can someone point me in the direction of how to implement an "autocomplete" search interface on the iPhone. I am assuming I will need to use a NSTimer to periodically check what has been typed and then submit that partial string to my data source and then display those.

我需要将它连接到返回JSON的现有Web服务

I need to connect it up with an existing web service returning JSON

首选教程或一些示例代码。

A tutorial or some sample code would be preferred.

谢谢

推荐答案

此Stack Overflow答案可能对您有所帮助。如果您使用 UISearchDisplayController ,则无需使用 NSTimer 来轮询搜索字段,因为更改为搜索字段将为您激活委托方法。

This Stack Overflow answer will likely help you. If you are using a UISearchDisplayController, you would not need to use an NSTimer to poll the search field, as changes to the search field will fire delegate methods for you.

在这些委托方法中,您可以根据字段的内容应用新的搜索谓词,然后刷新数据提取并显示可能的单词。

In those delegate methods, you may apply a new search predicate based on the contents of the field, and then refresh the data fetch and display possible words.

这篇关于iPhone的自动填充搜索示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆