自动完成的UITextField - iPhone SDK [英] UITextField Autocomplete - iPhone SDK

查看:96
本文介绍了自动完成的UITextField - iPhone SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出是否有实施的的UITextField 为特定值的自动填充功能的一种方式。

I am trying to figure out if there is a way to implement an autocomplete functionality in a UITextField for specific values.

我知道的UITextField 可以使用iPhone词典(很像搜索在Safari谷歌等)做到这一点,但我希望能够以编程方式有它正确一定值我指定。

I know that the UITextField can do this using the iPhone dictionary (much like searching google in safari, etc), but I want to be able to programmatically have it correct to certain values that I specify.

有谁知道有什么方法可以做到这一点?

Does anyone know of any way to do this?

非常感谢,
布雷特

Many thanks, Brett

推荐答案

布雷特,

我也非常相似,而这在最近的和相当大的项目上工作的东西。我们有自动完成术语的不断变化的列表,并内置自动完成他们身边。

I did something very similar to this while working on a recent and rather large project. We had a constantly changing list of auto complete terms and built an auto-complete around them.

首先,你要做出某种类型的自动完成控制器。它应该采取一个字符串,返回所有可能的自动完成条款该字符串。

First, you'll want to make some type of auto-complete controller. It should take a string and return all possible auto complete terms for that string.

-(NSArray *)completionsForString:(NSString *)myString;

然后,检查出UIMenuController类。这显示在许多应用中剪切/复制/粘贴选项的类。你可以得到它的共享实例,填充自己的菜单项,并显示它上面的文本字段。然后,用户可以简单地点击他们想要的词。

Then, check out the UIMenuController class. It's the class that shows the cut/copy/paste options in many applications. You can get the shared instance of it, populate the menu items yourself, and show it above the text field. The user can then simply tap the term they want.

在最后,该解决方案的工作非常出色了我们的需求。我希望它为你工作。

In the end, the solution worked really well for our needs. I hope it works for you.

这篇关于自动完成的UITextField - iPhone SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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