ios 自定义 UITextField 自动完成

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6483467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:31:40  来源:igfitidea点击:

Custom UITextField Autocomplete

iphoneios

提问by atiq

I want to implement a custom autocomplete functionality in a UITextField that will use the values provided by me, not the iPhone dictionary. Does any one knows how to do it or could point me to some resources?

我想在 UITextField 中实现自定义自动完成功能,该功能将使用我提供的值,而不是 iPhone 字典。有谁知道怎么做或可以指点我一些资源吗?

回答by codeperson

You can use this UITextField subclass:

你可以使用这个 UITextField 子类:

https://github.com/hoteltonight/HTAutocompleteTextField

https://github.com/hoteltonight/HTAutocompleteTextField

The example shows you how to use an array as the data source for the autosuggest text. The suggested text appears "ghosted", like you see in the address bar in a browser, as opposed to the speech bubble that iOS uses to autocomplete/suggest.

该示例向您展示了如何使用数组作为自动建议文本的数据源。建议的文本显示为“幻影”,就像您在浏览器的地址栏中看到的那样,而不是 iOS 用于自动完成/建议的语音气泡。

回答by illegal-immigrant

Here's Another alternative. Fully customizable and configurable.

这是另一种选择。完全可定制和可配置。

回答by alloc_iNit

Here's something same that I come across.

这是我遇到的相同情况。

http://www.radulucaciu.ro/iphone-autocomplete-class/5/

http://www.radulucaciu.ro/iphone-autocomplete-class/5/

回答by raulzito234

I've created a UITableViewController that you can add to your class very easily. The code is located here:

我已经创建了一个 UITableViewController,你可以很容易地将它添加到你的类中。代码位于此处:

https://github.com/raulzito234/AutoCompleteTableViewController

https://github.com/raulzito234/AutoCompleteTableViewController